mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Fixed #32866 -- Fixed trimming trailing punctuation from escaped string in urlize().
This commit is contained in:
parent
c51bf80d56
commit
68cc04887b
@ -283,8 +283,9 @@ def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False):
|
||||
middle_unescaped = html.unescape(middle)
|
||||
stripped = middle_unescaped.rstrip(TRAILING_PUNCTUATION_CHARS)
|
||||
if middle_unescaped != stripped:
|
||||
trail = middle[len(stripped):] + trail
|
||||
middle = middle[:len(stripped) - len(middle_unescaped)]
|
||||
punctuation_count = len(middle_unescaped) - len(stripped)
|
||||
trail = middle[-punctuation_count:] + trail
|
||||
middle = middle[:-punctuation_count]
|
||||
trimmed_something = True
|
||||
return lead, middle, trail
|
||||
|
||||
|
@ -250,6 +250,10 @@ class TestUtilsHtml(SimpleTestCase):
|
||||
'Search for google.com/?q=! and see.',
|
||||
'Search for <a href="http://google.com/?q=">google.com/?q=</a>! and see.'
|
||||
),
|
||||
(
|
||||
'Search for google.com/?q=1<! and see.',
|
||||
'Search for <a href="http://google.com/?q=1%3C">google.com/?q=1<</a>! and see.'
|
||||
),
|
||||
(
|
||||
lazystr('Search for google.com/?q=!'),
|
||||
'Search for <a href="http://google.com/?q=">google.com/?q=</a>!'
|
||||
|
Loading…
Reference in New Issue
Block a user