Commit f0c9bc55 authored by Malcolm Tredinnick's avatar Malcolm Tredinnick
Browse files

[1.0.X] Fixed #10675 -- Added unicode paragraph and line-sep handling to escapejs.

There were a couple of line breaking Unicode characters (\u2028 and
\u2029) that cause Javascript errors, at least in Firefox, if not
escaped. So now we do so. Based on a patch from rleland.

Backport of r10543 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10544 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent a83e4cb1
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -76,7 +76,9 @@ _base_js_escapes = (
    ('&', r'\x26'),
    ('=', r'\x3D'),
    ('-', r'\x2D'),
    (';', r'\x3B')
    (';', r'\x3B'),
    (u'\u2028', r'\u2028'),
    (u'\u2029', r'\u2029')
)

# Escape every ASCII character with a value less than 32.
+3 −0
Original line number Diff line number Diff line
@@ -83,6 +83,9 @@ u'and lots of whitespace: \\x0D\\x0A\\x09\\x0B\\x0C\\x08'
>>> escapejs(ur'<script>and this</script>')
u'\\x3Cscript\\x3Eand this\\x3C/script\\x3E'

>>> escapejs(u'paragraph separator:\u2029and line separator:\u2028')
u'paragraph separator:\\u2029and line separator:\\u2028'

>>> fix_ampersands(u'Jack & Jill & Jeroboam')
u'Jack &amp; Jill &amp; Jeroboam'