From 7a0634b5ad9abb0e0a88b97cb087554fb0e0238b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 31 May 2023 21:22:11 -0700 Subject: 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. --- README.md | 3 +++ test/simple.tl | 6 ++++++ who.tl | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a4baa48..12bb321 100644 --- a/README.md +++ b/README.md @@ -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 "\"\t") "\"")) "") + +;;; 44 +;;; Test that esc, escq and escj allow non-string. +(test (with-html-output-to-string (out) + (:p (esc 5) (escq 6) (escj 7))) + "

567

") diff --git a/who.tl b/who.tl index 5faf319..8ac2ebc 100644 --- a/who.tl +++ b/who.tl @@ -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)) -- cgit v1.2.3