Removed unnecessary str type from @keep_lazy decorator for escape()/escapejs().

This commit is contained in:
Mariusz Felisiak 2022-02-21 09:46:39 +01:00 committed by GitHub
parent 1299bc33e1
commit b626c5a979
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -14,7 +14,7 @@ from django.utils.safestring import SafeData, SafeString, mark_safe
from django.utils.text import normalize_newlines from django.utils.text import normalize_newlines
@keep_lazy(str, SafeString) @keep_lazy(SafeString)
def escape(text): def escape(text):
""" """
Return the given text with ampersands, quotes and angle brackets encoded Return the given text with ampersands, quotes and angle brackets encoded
@ -46,7 +46,7 @@ _js_escapes = {
_js_escapes.update((ord("%c" % z), "\\u%04X" % z) for z in range(32)) _js_escapes.update((ord("%c" % z), "\\u%04X" % z) for z in range(32))
@keep_lazy(str, SafeString) @keep_lazy(SafeString)
def escapejs(value): def escapejs(value):
"""Hex encode characters for use in JavaScript strings.""" """Hex encode characters for use in JavaScript strings."""
return mark_safe(str(value).translate(_js_escapes)) return mark_safe(str(value).translate(_js_escapes))