diff options
-rw-r--r-- | test/simple.tl | 13 | ||||
-rw-r--r-- | who.tl | 14 |
2 files changed, 26 insertions, 1 deletions
diff --git a/test/simple.tl b/test/simple.tl index 3601814..b9d1a65 100644 --- a/test/simple.tl +++ b/test/simple.tl @@ -449,3 +449,16 @@ (with-html-output-to-string (out) (:foo (fmt "<a href=\"foo.html\">click</a>")))) "<foo><a href=\"foo.html\">click</a></foo>") + +;;; 41 +;;; Test that warning is produced when any of the WHO local macros are used in +;;; an Lisp expression that calculates an attribute +(each ((sym '(htm noesc-fmt fmt esc str))) + (test (catch + (eval '(progn + (with-html-output-to-string (out) + (:foo :attr (,sym "abc"))) + nil)) + (warning (x) + t)) + t)) @@ -85,6 +85,18 @@ (set body (rest sexp))))) (convert-tag-to-string-list tag attr-list body body-fn))) +(defun attr-warning-macrolet (form) + (with-gensyms (warn) + ^(macrolet ((,warn (f . rest) + ^(compile-warning ,f + "not recommended in attribute expr"))) + (macrolet ((htm (:form f . rest) (,warn f) f) + (noesc-fmt (:form f . rest) (,warn f) f) + (fmt (:form f . rest) (,warn f) f) + (esc (:form f . rest) (,warn f) f) + (str (:form f . rest) (,warn f) f)) + ,form)))) + ;; Helper function for convert-tag-to-string-list which converts the ;; alist attr-list of attributes into a list of strings and/or Lisp ;; forms. @@ -110,7 +122,7 @@ ` @attr=@aqc@(tostringp eval)@aqc`) (t ` @attr=@aqc@(html-encode (tostringp eval))@aqc`))) ;; For non-constant, do the same things as above but at runtime - ^(let ((,=var= ,val)) + ^(let ((,=var= ,(attr-warning-macrolet val))) (cond ((null ,=var=)) ((eq ,=var= t) |