Skip to content

Commit a05cd74

Browse files
Fix exception on a link containing a newline
1 parent cbf127d commit a05cd74

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

tests/test_urls.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ def test_urls():
5050
expect = '\t<p><a href="/test/">A link that starts with a space&#8221; raises</a> an exception.</p>'
5151
assert result == expect
5252

53+
result = t.parse('A link that "contains a\nnewline":/test/ raises an exception.')
54+
expect = '\t<p>A link that <a href="/test/">contains a\nnewline</a> raises an exception.</p>'
55+
assert result == expect
56+
5357
def test_rel_attribute():
5458
t = Textile(rel='nofollow')
5559
result = t.parse('"$":http://domain.tld')

textile/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,9 @@ def fLink(self, m):
759759
$'''.format(cls_re_s, regex_snippets['space']), inner,
760760
flags=re.X | re.U)
761761

762-
atts = m.group('atts') or ''
763-
text = m.group('text') or '' or inner
764-
title = m.group('title') or ''
762+
atts = (m and m.group('atts')) or ''
763+
text = (m and m.group('text')) or inner
764+
title = (m and m.group('title')) or ''
765765

766766
pop, tight = '', ''
767767
counts = { '[': None, ']': url.count(']'), '(': None, ')': None }

0 commit comments

Comments
 (0)