Ticket #7177: 7177.patch
File 7177.patch, 3.0 KB (added by , 16 years ago) |
---|
-
django/template/defaultfilters.py
63 63 capfirst = stringfilter(capfirst) 64 64 65 65 _js_escapes = ( 66 ('\\', '\\\\'), 67 ('"', '\\"'), 68 ("'", "\\'"), 69 ('\n', '\\n'), 70 ('\r', '\\r'), 71 ('\b', '\\b'), 72 ('\f', '\\f'), 73 ('\t', '\\t'), 74 ('\v', '\\v'), 75 ('</', '<\\/'), 66 ('\\', r'\x5C'), 67 ('\'', r'\x27'), 68 ('"', r'\x22'), 69 ('>', r'\x3E'), 70 ('<', r'\x3C'), 71 ('&', r'\x26'), 72 ('=', r'\x3D'), 73 ('-', r'\x2D'), 74 (';', r'\x3B'), 75 ('\x00', r'\x00'), 76 ('\x01', r'\x01'), 77 ('\x02', r'\x02'), 78 ('\x03', r'\x03'), 79 ('\x04', r'\x04'), 80 ('\x05', r'\x05'), 81 ('\x06', r'\x06'), 82 ('\x07', r'\x07'), 83 ('\x08', r'\x08'), 84 ('\x09', r'\x09'), 85 ('\x0A', r'\x0A'), 86 ('\x0B', r'\x0B'), 87 ('\x0C', r'\x0C'), 88 ('\x0D', r'\x0D'), 89 ('\x0E', r'\x0E'), 90 ('\x0F', r'\x0F'), 91 ('\x10', r'\x10'), 92 ('\x11', r'\x11'), 93 ('\x12', r'\x12'), 94 ('\x13', r'\x13'), 95 ('\x14', r'\x14'), 96 ('\x15', r'\x15'), 97 ('\x16', r'\x16'), 98 ('\x17', r'\x17'), 99 ('\x18', r'\x18'), 100 ('\x19', r'\x19'), 101 ('\x1A', r'\x1A'), 102 ('\x1B', r'\x1B'), 103 ('\x1C', r'\x1C'), 104 ('\x1D', r'\x1D'), 105 ('\x1E', r'\x1E'), 106 ('\x1F', r'\x1F'), 76 107 ) 77 108 def escapejs(value): 78 """ Backslash-escapes characters for use in JavaScript strings."""109 """Hex encodes characters for use in JavaScript strings.""" 79 110 for bad, good in _js_escapes: 80 111 value = value.replace(bad, good) 81 112 return value -
tests/regressiontests/templates/filters.py
249 249 'autoescape-stringfilter02': (r'{% autoescape off %}{{ unsafe|capfirst }}{% endautoescape %}', {'unsafe': UnsafeClass()}, 'You & me'), 250 250 'autoescape-stringfilter03': (r'{{ safe|capfirst }}', {'safe': SafeClass()}, 'You > me'), 251 251 'autoescape-stringfilter04': (r'{% autoescape off %}{{ safe|capfirst }}{% endautoescape %}', {'safe': SafeClass()}, 'You > me'), 252 253 'escapejs01': (r'{{ a|escapejs }}', {'a': 'testing\r\njavascript \'string" <b>escaping</b>'}, 'testing\\x0D\\x0Ajavascript \\x27string\\x22 \\x3Cb\\x3Eescaping\\x3C/b\\x3E'), 254 'escapejs02': (r'{% autoescape off %}{{ a|escapejs }}{% endautoescape %}', {'a': 'testing\r\njavascript \'string" <b>escaping</b>'}, 'testing\\x0D\\x0Ajavascript \\x27string\\x22 \\x3Cb\\x3Eescaping\\x3C/b\\x3E'), 252 255 } 253 256 -
AUTHORS
419 419 ymasuda@ethercube.com 420 420 Jarek Zgoda <jarek.zgoda@gmail.com> 421 421 Cheng Zhang 422 Collin Grady <collin@collingrady.com> 422 423 423 424 A big THANK YOU goes to: 424 425