File tree Expand file tree Collapse file tree 4 files changed +24
–10
lines changed
Expand file tree Collapse file tree 4 files changed +24
–10
lines changed Original file line number Diff line number Diff line change @@ -408,23 +408,21 @@ def trim_punctuation(self, word):
408408 trimmed_something = True
409409 counts [closing ] -= strip
410410
411- rstripped = middle .rstrip (self .trailing_punctuation_chars_no_semicolon )
411+ amp = middle .rfind ("&" )
412+ if amp == - 1 :
413+ rstripped = middle .rstrip (self .trailing_punctuation_chars )
414+ else :
415+ rstripped = middle .rstrip (self .trailing_punctuation_chars_no_semicolon )
412416 if rstripped != middle :
413417 trail = middle [len (rstripped ) :] + trail
414418 middle = rstripped
415419 trimmed_something = True
416420
417421 if self .trailing_punctuation_chars_has_semicolon and middle .endswith (";" ):
418422 # Only strip if not part of an HTML entity.
419- amp = middle .rfind ("&" )
420- if amp == - 1 :
421- can_strip = True
422- else :
423- potential_entity = middle [amp :]
424- escaped = html .unescape (potential_entity )
425- can_strip = (escaped == potential_entity ) or escaped .endswith (";" )
426-
427- if can_strip :
423+ potential_entity = middle [amp :]
424+ escaped = html .unescape (potential_entity )
425+ if escaped == potential_entity or escaped .endswith (";" ):
428426 rstripped = middle .rstrip (";" )
429427 amount_stripped = len (middle ) - len (rstripped )
430428 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 @@ -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 @@ -359,6 +359,8 @@ def test_urlize_unchanged_inputs(self):
359359 "[(" * 100_000 + ":" + ")]" * 100_000 ,
360360 "([[" * 100_000 + ":" + "]])" * 100_000 ,
361361 "&:" + ";" * 100_000 ,
362+ "&.;" * 100_000 ,
363+ ".;" * 100_000 ,
362364 )
363365 for value in tests :
364366 with self .subTest (value = value ):
You can’t perform that action at this time.
0 commit comments