diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-05-31 21:22:11 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-05-31 21:22:11 -0700 |
commit | 7a0634b5ad9abb0e0a88b97cb087554fb0e0238b (patch) | |
tree | 4102e608bba8704935032bcddeb6abc88e0bf9bc | |
parent | 0955f80732a34d0457b14bf1fa5df1eb00e95bc1 (diff) | |
download | tl-who-7a0634b5ad9abb0e0a88b97cb087554fb0e0238b.tar.gz tl-who-7a0634b5ad9abb0e0a88b97cb087554fb0e0238b.tar.bz2 tl-who-7a0634b5ad9abb0e0a88b97cb087554fb0e0238b.zip |
esc, escq: accept non-numeric arguments.
* who.tl (with-html-output): Arrange for
tostringp to be called on argument of esc and escq.
* test/simple.tl: New test 44.
* README.tl: mention as a difference from CL-WHO.
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | test/simple.tl | 6 | ||||
-rw-r--r-- | who.tl | 4 |
3 files changed, 11 insertions, 2 deletions
@@ -192,6 +192,9 @@ Here are the differences to be aware of: a Javascript string literal, which is itself embedded in a HTML `script` tag. +* TL-WHO's `esc` accepts arguments which are not strings. They + are turned to a string using `tostringp`, and HTML-escaped. + Additionally, users (of CL-WHO and TL-WHO alike) are advised to watch for the following issue: the CL-WHO documentation is not accurately maintained and makes some references to material that no longer exists in CL-WHO, such as the diff --git a/test/simple.tl b/test/simple.tl index 8b8cb50..3ed4685 100644 --- a/test/simple.tl +++ b/test/simple.tl @@ -474,3 +474,9 @@ (test (with-html-output-to-string (out) (:script "var x = \"" (escj "\"</script>\t") "\"")) "<script>var x = \"\\\"<\\/script>\\t\"</script>") + +;;; 44 +;;; Test that esc, escq and escj allow non-string. +(test (with-html-output-to-string (out) + (:p (esc 5) (escq 6) (escj 7))) + "<p>567</p>") @@ -258,11 +258,11 @@ (esc (thing) (with-gensyms (result) ^(whenlet ((,result ,thing)) - (put-string (html-encode* ,result) ,',var)))) + (put-string (html-encode* (tostringp ,result)) ,',var)))) (escq (thing) (with-gensyms (result) ^(whenlet ((,result ,thing)) - (put-string (html-encode ,result) ,',var)))) + (put-string (html-encode (tostringp ,result)) ,',var)))) (escj (thing) (with-gensyms (result) ^(whenlet ((,result ,thing)) |