Skip to content

Commit cbf127d

Browse files
Fix exception on link that starts with a space
1 parent 10f49ca commit cbf127d

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

tests/test_urls.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ def test_urls():
4646
expect = '\t<p>A link that starts with an h is <a href="/test/">handled</a> incorrectly.</p>'
4747
assert result == expect
4848

49+
result = t.parse('A link that starts with a space" raises":/test/ an exception.')
50+
expect = '\t<p><a href="/test/">A link that starts with a space&#8221; raises</a> an exception.</p>'
51+
assert result == expect
52+
4953
def test_rel_attribute():
5054
t = Textile(rel='nofollow')
5155
result = t.parse('"$":http://domain.tld')

textile/core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,10 @@ def markStartOfLinks(self, text):
672672
balanced = balanced - 1
673673
if re.search(r'\S$', possibility, flags=re.U): # pragma: no branch
674674
balanced = balanced + 1
675-
possibility = possible_start_quotes.pop()
675+
try:
676+
possibility = possible_start_quotes.pop()
677+
except IndexError:
678+
break
676679
else:
677680
# If quotes occur next to each other, we get zero
678681
# length strings. eg. ...""Open the door,

0 commit comments

Comments
 (0)