Skip to content

Commit dcf8902

Browse files
committed
test(math): cover escaped math output
1 parent c4093c4 commit dcf8902

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tests/test_security_math.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from unittest import TestCase
2+
3+
from mistune import create_markdown
4+
5+
6+
class TestMathSecurity(TestCase):
7+
def test_math_plugin_escapes_math_content(self):
8+
md = create_markdown(escape=True, plugins=["math"])
9+
10+
inline_html = md("$<script>alert(1)</script>$\n")
11+
block_html = md("$$\n<script>alert(1)</script>\n$$\n")
12+
13+
self.assertIn("&lt;script&gt;alert(1)&lt;/script&gt;", inline_html)
14+
self.assertIn("&lt;script&gt;alert(1)&lt;/script&gt;", block_html)
15+
self.assertNotIn("<script>", inline_html)
16+
self.assertNotIn("<script>", block_html)

0 commit comments

Comments
 (0)