Skip to content
Open
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 @@ -17,6 +17,7 @@
- [pull #720] Add `wiki-links` extra for `[[Page Name]]` style links (#221)
- [pull #722] Harden URL safety checks and sanitization in safe mode (#721)
- [pull #728] Fix XSS from zero-padded colon entities in link URLs (#726)
- [pull #734] Fix empty list items being parsed as nested lists (#167)


## python-markdown2 2.5.5
Expand Down
2 changes: 1 addition & 1 deletion lib/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,7 @@ def _do_lists(self, text: str) -> str:
(\n)? # leading line = \1
(^[ \t]*) # leading whitespace = \2
(?P<marker>{}) [ \t]+ # list marker = \3
((?:.+?) # list item text = \4
((?:.*?) # list item text = \4 (may be empty)
(\n{{1,2}})) # eols = \5
(?= \n* (\Z | \2 (?P<next_marker>{}) [ \t]+))
'''.format(_marker_any, _marker_any),
Expand Down
38 changes: 38 additions & 0 deletions test/tm-cases/empty_list_items_issue167.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<ol>
<li></li>
<li></li>
</ol>

<p>Empty bullet items:</p>

<ul>
<li></li>
<li></li>
</ul>

<p>An empty item between others:</p>

<ul>
<li>foo</li>
<li></li>
<li>bar</li>
</ul>

<p>An empty numbered item:</p>

<ol>
<li>foo</li>
<li></li>
<li>bar</li>
</ol>

<p>Empty items in a sub-list:</p>

<ul>
<li>foo
<ul>
<li></li>
<li></li>
</ul></li>
<li>bar</li>
</ul>
26 changes: 26 additions & 0 deletions test/tm-cases/empty_list_items_issue167.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
1.
2.

Empty bullet items:

-
-

An empty item between others:

- foo
-
- bar

An empty numbered item:

1. foo
2.
3. bar

Empty items in a sub-list:

- foo
-
-
- bar
4 changes: 1 addition & 3 deletions test/tm-cases/xss_smuggling_spans_in_image_attrs.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
<p><a href="#">x</a></p>

<ul>
<li>
<ul>
<li></li>
<li><img src="x" alt="" title="&lt;code&gt;![](&lt;/code&gt;" /> onerror=alert(origin) )</li>
</ul></li>
</ul>

<p><img src="code&gt;&lt;A B=&quot;
Expand Down