Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More robust XSS check #315

Merged
merged 1 commit into from Dec 5, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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/)