Skip to content

Commit

Permalink
Merge pull request #353 from zoo-digital/issue_348
Browse files Browse the repository at this point in the history
Issue 348
  • Loading branch information
nicholasserra committed May 4, 2020
2 parents 4d2fc79 + 0c05438 commit aa06927
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/markdown2.py
Expand Up @@ -2164,11 +2164,14 @@ 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+?(?!\w).+?[\s/]+?)")

def _encode_incomplete_tags(self, text):
if self.safe_mode not in ("replace", "escape"):
return text

if text.endswith(">"):
return text # this is not an incomplete tag, this is a link in the form <http://x.y.z>

return self._incomplete_tags_re.sub("&lt;\\1", text)

Expand Down
1 change: 1 addition & 0 deletions test/tm-cases/issue348_incomplete_tag.html
@@ -0,0 +1 @@
<p>&lt;lol@/ //id="pwn"//onclick="alert(1)"//<strong>abc</strong></p>
1 change: 1 addition & 0 deletions test/tm-cases/issue348_incomplete_tag.opts
@@ -0,0 +1 @@
{"safe_mode": "escape"}
1 change: 1 addition & 0 deletions test/tm-cases/issue348_incomplete_tag.text
@@ -0,0 +1 @@
<lol@/ //id="pwn"//onclick="alert(1)"//**abc**

0 comments on commit aa06927

Please sign in to comment.