From b90ecda752fa1d8ffa363ba26c08e1f2a5094901 Mon Sep 17 00:00:00 2001 From: Vlad Ciobanu <95963142+vl3c@users.noreply.github.com> Date: Sat, 11 Jul 2026 22:37:07 +0300 Subject: [PATCH] Fix chat XSS and harden login, request size, and secret key XSS (client): - markdown_parser.py now HTML-escapes source text before any markdown transformation, so raw ") + self.assertNotIn(")") + self.assertNotIn(" None: + """Allowed https links must still render as real anchors.""" + result = self.parser.parse("[ok](https://example.com)") + self.assertIn('ok', result) + + def test_mailto_link_still_renders(self) -> None: + """mailto: links are allowed.""" + result = self.parser.parse("[mail](mailto:a@b.com)") + self.assertIn('mail', result) + + def test_relative_link_still_renders(self) -> None: + """Relative URLs (no scheme) are allowed.""" + result = self.parser.parse("[rel](/path/page)") + self.assertIn('rel', result) + + def test_normal_markdown_still_renders_after_escaping(self) -> None: + """Bold, code, and headers must still render once escaping is in place.""" + result = self.parser.parse("# Title\n\nSome **bold** and `code` here") + self.assertIn("
code", result)
+
+ def test_angle_brackets_in_prose_are_escaped(self) -> None:
+ """Comparison operators in prose render as escaped entities."""
+ result = self.parser.parse("a < b and c > d")
+ self.assertIn("a < b and c > d", result)
+ self.assertNotIn(" None:
+ """A code block containing \n```"
+ result = self.parser.parse(code_block)
+ self.assertIn("", result)
+ self.assertIn("<script>", result)
+ self.assertNotIn("