Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- [pull #687] Fix AssertionError hashing HTML blocks spread over multiple lines (#686)
- [pull #692] Fix XSS from code spans in link titles (#691)
- [pull #695] Fix XSS issue from incomplete tags with no attributes (#694)


## python-markdown2 2.5.5
Expand Down
2 changes: 1 addition & 1 deletion lib/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,7 @@ def _encode_amps_and_angles(self, text: str) -> str:
text = self._naked_gt_re.sub('>', text)
return text

_incomplete_tags_re = re.compile(r"\\*<(!--|/?\w+?(?!\w)\s*?.+?(?:[\s/]+?|$))")
_incomplete_tags_re = re.compile(r"\\*<(!--|/?\w+?(?!\w)\s*?.*?(?:[\s/]+?|$))")

def _encode_incomplete_tags(self, text: str) -> str:
if self.safe_mode not in ("replace", "escape"):
Expand Down
2 changes: 2 additions & 0 deletions test/tm-cases/incomplete_tag_xss_issue694.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<p>&lt;iframe
&lt;http:&gt; srcdoc="&lt;script&gt;alert()&lt;/script&gt;" a=</p>
1 change: 1 addition & 0 deletions test/tm-cases/incomplete_tag_xss_issue694.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{'safe_mode': 'escape'}
2 changes: 2 additions & 0 deletions test/tm-cases/incomplete_tag_xss_issue694.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<iframe
<http:> srcdoc="<script>alert()</script>" a=
Loading