Skip to content

Commit

Permalink
Merge pull request #315 from trentm/xss-fix-retry
Browse files Browse the repository at this point in the history
More robust XSS check
  • Loading branch information
nicholasserra committed Dec 5, 2018
2 parents 679d3da + c86fce7 commit 1fb702d
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 1fb702d

Please sign in to comment.