Skip to content

Commit

Permalink
More robust XSS check
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasserra committed Nov 19, 2018
1 parent 679d3da commit c86fce7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/markdown2.py
Expand Up @@ -2134,7 +2134,7 @@ def _encode_amps_and_angles(self, text):
text = self._naked_gt_re.sub('>', text)
return text

_incomplete_tags_re = re.compile("<(/?\w+\s+)")
_incomplete_tags_re = re.compile("<(/?\w+[\s/]+?)")

def _encode_incomplete_tags(self, text):
if self.safe_mode not in ("replace", "escape"):
Expand Down
4 changes: 4 additions & 0 deletions test/tm-cases/CVE-2018-5773.html
@@ -1,3 +1,7 @@
<p>&lt;img src="" onerror=alert(/XSS/) </p>

<p>&lt;/img src="" onerror=alert(/XSS/) </p>

<p>&lt;img/src="" onerror=alert(/XSS/) </p>

<p>&lt;/img/src="" onerror=alert(/XSS/) </p>
4 changes: 4 additions & 0 deletions test/tm-cases/CVE-2018-5773.text
@@ -1,3 +1,7 @@
<img src="" onerror=alert(/XSS/)

</img src="" onerror=alert(/XSS/)

<img/src="" onerror=alert(/XSS/)

</img/src="" onerror=alert(/XSS/)

0 comments on commit c86fce7

Please sign in to comment.