1
0
mirror of https://github.com/django/django.git synced 2025-10-26 15:16:09 +00:00

More attacking E302 violators

This commit is contained in:
Alex Gaynor
2013-11-02 13:12:09 -07:00
parent 65c4ac3b24
commit 7548aa8ffd
150 changed files with 433 additions and 1 deletions

View File

@@ -56,11 +56,13 @@ _js_escapes = {
# Escape every ASCII character with a value less than 32.
_js_escapes.update((ord('%c' % z), '\\u%04X' % z) for z in range(32))
def escapejs(value):
"""Hex encodes characters for use in JavaScript strings."""
return mark_safe(force_text(value).translate(_js_escapes))
escapejs = allow_lazy(escapejs, six.text_type)
def conditional_escape(text):
"""
Similar to escape(), except that it doesn't operate on pre-escaped strings.