mirror of https://github.com/django/django.git
Refs #27795 -- Replaced force_text() calls with str() in django.utils.html.
This commit is contained in:
parent
d4373b6da4
commit
968329b5c2
|
@ -7,7 +7,6 @@ from urllib.parse import (
|
||||||
parse_qsl, quote, unquote, urlencode, urlsplit, urlunsplit,
|
parse_qsl, quote, unquote, urlencode, urlsplit, urlunsplit,
|
||||||
)
|
)
|
||||||
|
|
||||||
from django.utils.encoding import force_text
|
|
||||||
from django.utils.functional import Promise, keep_lazy, keep_lazy_text
|
from django.utils.functional import Promise, keep_lazy, keep_lazy_text
|
||||||
from django.utils.http import RFC3986_GENDELIMS, RFC3986_SUBDELIMS
|
from django.utils.http import RFC3986_GENDELIMS, RFC3986_SUBDELIMS
|
||||||
from django.utils.safestring import SafeData, SafeText, mark_safe
|
from django.utils.safestring import SafeData, SafeText, mark_safe
|
||||||
|
@ -190,7 +189,7 @@ def strip_tags(value):
|
||||||
"""Return the given HTML with all tags stripped."""
|
"""Return the given HTML with all tags stripped."""
|
||||||
# Note: in typical case this loop executes _strip_once once. Loop condition
|
# Note: in typical case this loop executes _strip_once once. Loop condition
|
||||||
# is redundant, but helps to reduce number of executions of _strip_once.
|
# is redundant, but helps to reduce number of executions of _strip_once.
|
||||||
value = force_text(value)
|
value = str(value)
|
||||||
while '<' in value and '>' in value:
|
while '<' in value and '>' in value:
|
||||||
new_value = _strip_once(value)
|
new_value = _strip_once(value)
|
||||||
if len(new_value) >= len(value):
|
if len(new_value) >= len(value):
|
||||||
|
@ -203,7 +202,7 @@ def strip_tags(value):
|
||||||
@keep_lazy_text
|
@keep_lazy_text
|
||||||
def strip_spaces_between_tags(value):
|
def strip_spaces_between_tags(value):
|
||||||
"""Return the given HTML with spaces between tags removed."""
|
"""Return the given HTML with spaces between tags removed."""
|
||||||
return re.sub(r'>\s+<', '><', force_text(value))
|
return re.sub(r'>\s+<', '><', str(value))
|
||||||
|
|
||||||
|
|
||||||
def smart_urlquote(url):
|
def smart_urlquote(url):
|
||||||
|
@ -213,8 +212,7 @@ def smart_urlquote(url):
|
||||||
# Tilde is part of RFC3986 Unreserved Characters
|
# Tilde is part of RFC3986 Unreserved Characters
|
||||||
# http://tools.ietf.org/html/rfc3986#section-2.3
|
# http://tools.ietf.org/html/rfc3986#section-2.3
|
||||||
# See also http://bugs.python.org/issue16285
|
# See also http://bugs.python.org/issue16285
|
||||||
segment = quote(segment, safe=RFC3986_SUBDELIMS + RFC3986_GENDELIMS + '~')
|
return quote(segment, safe=RFC3986_SUBDELIMS + RFC3986_GENDELIMS + '~')
|
||||||
return force_text(segment)
|
|
||||||
|
|
||||||
# Handle IDN before quoting.
|
# Handle IDN before quoting.
|
||||||
try:
|
try:
|
||||||
|
@ -315,7 +313,7 @@ def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False):
|
||||||
trimmed_something = True
|
trimmed_something = True
|
||||||
return lead, middle, trail
|
return lead, middle, trail
|
||||||
|
|
||||||
words = word_split_re.split(force_text(text))
|
words = word_split_re.split(str(text))
|
||||||
for i, word in enumerate(words):
|
for i, word in enumerate(words):
|
||||||
if '.' in word or '@' in word or ':' in word:
|
if '.' in word or '@' in word or ':' in word:
|
||||||
# lead: Current punctuation trimmed from the beginning of the word.
|
# lead: Current punctuation trimmed from the beginning of the word.
|
||||||
|
|
Loading…
Reference in New Issue