mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Refs #30686 -- Fixed text truncation for negative or zero lengths.
This commit is contained in:
committed by
Mariusz Felisiak
parent
3e820d10f8
commit
70f39e46f8
@@ -104,6 +104,8 @@ class Truncator(SimpleLazyObject):
|
||||
"""
|
||||
self._setup()
|
||||
length = int(num)
|
||||
if length <= 0:
|
||||
return ""
|
||||
text = unicodedata.normalize("NFC", self._wrapped)
|
||||
|
||||
# Calculate the length to truncate to (max length - end_text length)
|
||||
@@ -144,6 +146,8 @@ class Truncator(SimpleLazyObject):
|
||||
"""
|
||||
self._setup()
|
||||
length = int(num)
|
||||
if length <= 0:
|
||||
return ""
|
||||
if html:
|
||||
return self._truncate_html(length, truncate, self._wrapped, length, True)
|
||||
return self._text_words(length, truncate)
|
||||
|
||||
Reference in New Issue
Block a user