File tree Expand file tree Collapse file tree 3 files changed +17
–10
lines changed
Expand file tree Collapse file tree 3 files changed +17
–10
lines changed Original file line number Diff line number Diff line change @@ -378,23 +378,21 @@ def trim_punctuation(self, word):
378378 trimmed_something = True
379379 counts [closing ] -= strip
380380
381- rstripped = middle .rstrip (self .trailing_punctuation_chars_no_semicolon )
381+ amp = middle .rfind ("&" )
382+ if amp == - 1 :
383+ rstripped = middle .rstrip (self .trailing_punctuation_chars )
384+ else :
385+ rstripped = middle .rstrip (self .trailing_punctuation_chars_no_semicolon )
382386 if rstripped != middle :
383387 trail = middle [len (rstripped ) :] + trail
384388 middle = rstripped
385389 trimmed_something = True
386390
387391 if self .trailing_punctuation_chars_has_semicolon and middle .endswith (";" ):
388392 # Only strip if not part of an HTML entity.
389- amp = middle .rfind ("&" )
390- if amp == - 1 :
391- can_strip = True
392- else :
393- potential_entity = middle [amp :]
394- escaped = html .unescape (potential_entity )
395- can_strip = (escaped == potential_entity ) or escaped .endswith (";" )
396-
397- if can_strip :
393+ potential_entity = middle [amp :]
394+ escaped = html .unescape (potential_entity )
395+ if escaped == potential_entity or escaped .endswith (";" ):
398396 rstripped = middle .rstrip (";" )
399397 amount_stripped = len (middle ) - len (rstripped )
400398 if amp > - 1 and amount_stripped > 1 :
Original file line number Diff line number Diff line change @@ -16,6 +16,13 @@ consumption.
1616
1717To avoid this, decimals with more than 200 digits are now returned as is.
1818
19+ CVE-2024-41990: Potential denial-of-service vulnerability in ``django.utils.html.urlize()``
20+ ===========================================================================================
21+
22+ :tfilter:`urlize` and :tfilter:`urlizetrunc` were subject to a potential
23+ denial-of-service attack via very large inputs with a specific sequence of
24+ characters.
25+
1926Bugfixes
2027========
2128
Original file line number Diff line number Diff line change @@ -349,6 +349,8 @@ def test_urlize_unchanged_inputs(self):
349349 "[(" * 100_000 + ":" + ")]" * 100_000 ,
350350 "([[" * 100_000 + ":" + "]])" * 100_000 ,
351351 "&:" + ";" * 100_000 ,
352+ "&.;" * 100_000 ,
353+ ".;" * 100_000 ,
352354 )
353355 for value in tests :
354356 with self .subTest (value = value ):
You can’t perform that action at this time.
0 commit comments