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 @@ -5,6 +5,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)
- [pull #700] Fix XSS from code spans in image alt text (#699)


## python-markdown2 2.5.5
Expand Down
4 changes: 4 additions & 0 deletions lib/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3279,6 +3279,10 @@ def run(self, text: str):
curr_pos = start_idx + 1
continue

if link_text and self.md.safe_mode:
# expose code span contents for escaping - fix #699
link_text = self.md._unhash_html_spans(link_text, spans=False, code=True)

start_idx -= 1
result, skip = self.process_image(url, title_str, link_text)
elif start_idx >= anchor_allowed_pos:
Expand Down
1 change: 1 addition & 0 deletions test/tm-cases/xss_issue699.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p><img src="" alt="&lt;code&gt;&quot; onerror=&quot;alert(1)//&lt;/code&gt;" /></p>
1 change: 1 addition & 0 deletions test/tm-cases/xss_issue699.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"safe_mode": "escape"}
1 change: 1 addition & 0 deletions test/tm-cases/xss_issue699.text
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
![`" onerror="alert(1)//`]()
Loading