summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorShipeng Feng <fsp261@gmail.com>2021-07-07 17:19:33 +0800
committerGitHub <noreply@github.com>2021-07-07 11:19:33 +0200
commit68cc04887b3c5b7ce8f28eaae5de266db99ca9a6 (patch)
tree3dc9bff8bf9ef5198ae57b4e102e5abe08295282 /django
parentc51bf80d56cbcdbec1b243b8db086f35b4598947 (diff)
Fixed #32866 -- Fixed trimming trailing punctuation from escaped string in urlize().
Diffstat (limited to 'django')
-rw-r--r--django/utils/html.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/utils/html.py b/django/utils/html.py
index 3bc02b8dd3..bd58317a79 100644
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -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