Skip to content

Commit cac71b6

Browse files
Merge pull request #734 from LuisFigueroaG/fix/empty-list-items
Fix empty list items being parsed as nested lists
2 parents eec056c + 527f6ae commit cac71b6

5 files changed

Lines changed: 67 additions & 4 deletions

File tree

‎CHANGES.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- [pull #720] Add `wiki-links` extra for `[[Page Name]]` style links (#221)
2020
- [pull #722] Harden URL safety checks and sanitization in safe mode (#721)
2121
- [pull #728] Fix XSS from zero-padded colon entities in link URLs (#726)
22+
- [pull #734] Fix empty list items being parsed as nested lists (#167)
2223

2324

2425
## python-markdown2 2.5.5

‎lib/markdown2.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,7 @@ def _do_lists(self, text: str) -> str:
18831883
(\n)? # leading line = \1
18841884
(^[ \t]*) # leading whitespace = \2
18851885
(?P<marker>{}) [ \t]+ # list marker = \3
1886-
((?:.+?) # list item text = \4
1886+
((?:.*?) # list item text = \4 (may be empty)
18871887
(\n{{1,2}})) # eols = \5
18881888
(?= \n* (\Z | \2 (?P<next_marker>{}) [ \t]+))
18891889
'''.format(_marker_any, _marker_any),
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<ol>
2+
<li></li>
3+
<li></li>
4+
</ol>
5+
6+
<p>Empty bullet items:</p>
7+
8+
<ul>
9+
<li></li>
10+
<li></li>
11+
</ul>
12+
13+
<p>An empty item between others:</p>
14+
15+
<ul>
16+
<li>foo</li>
17+
<li></li>
18+
<li>bar</li>
19+
</ul>
20+
21+
<p>An empty numbered item:</p>
22+
23+
<ol>
24+
<li>foo</li>
25+
<li></li>
26+
<li>bar</li>
27+
</ol>
28+
29+
<p>Empty items in a sub-list:</p>
30+
31+
<ul>
32+
<li>foo
33+
<ul>
34+
<li></li>
35+
<li></li>
36+
</ul></li>
37+
<li>bar</li>
38+
</ul>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
1.
2+
2.
3+
4+
Empty bullet items:
5+
6+
-
7+
-
8+
9+
An empty item between others:
10+
11+
- foo
12+
-
13+
- bar
14+
15+
An empty numbered item:
16+
17+
1. foo
18+
2.
19+
3. bar
20+
21+
Empty items in a sub-list:
22+
23+
- foo
24+
-
25+
-
26+
- bar

‎test/tm-cases/xss_smuggling_spans_in_image_attrs.html‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99
<p><a href="#">x</a></p>
1010

1111
<ul>
12-
<li>
13-
<ul>
12+
<li></li>
1413
<li><img src="x" alt="" title="&lt;code&gt;![](&lt;/code&gt;" /> onerror=alert(origin) )</li>
15-
</ul></li>
1614
</ul>
1715

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

0 commit comments

Comments
 (0)