diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index e6492dc..6447a4e 100644
a
|
b
|
_base_js_escapes = (
|
86 | 86 | _js_escapes = (_base_js_escapes + |
87 | 87 | tuple([('%c' % z, '\\x%02X' % z) for z in range(32)])) |
88 | 88 | |
| 89 | _js_escapes_dict={} |
| 90 | for k, v in _js_escapes: |
| 91 | _js_escapes_dict[k]=v |
| 92 | |
| 93 | _js_escapes_re = re.compile(u'[\u0000-\u001f\u2028\u2029]|\\\\|\'|"|>|<|&|=|-|;') |
| 94 | |
89 | 95 | def escapejs(value): |
90 | 96 | """Hex encodes characters for use in JavaScript strings.""" |
91 | | for bad, good in _js_escapes: |
92 | | value = value.replace(bad, good) |
93 | | return value |
| 97 | return _js_escapes_re.sub(lambda m: _js_escapes_dict[m.group(0)], value) |
94 | 98 | escapejs = stringfilter(escapejs) |
95 | 99 | |
96 | 100 | def fix_ampersands(value): |