Author: mtredinnick
Date: 2009-04-11 23:55:41 -0500 (Sat, 11 Apr 2009)
New Revision: 10543
Modified:
django/trunk/django/template/defaultfilters.py
django/trunk/tests/regressiontests/defaultfilters/tests.py
Log:
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.
Modified: django/trunk/django/template/defaultfilters.py
===================================================================
--- django/trunk/django/template/defaultfilters.py 2009-04-12 04:15:45 UTC
(rev 10542)
+++ django/trunk/django/template/defaultfilters.py 2009-04-12 04:55:41 UTC
(rev 10543)
@@ -76,7 +76,9 @@
('&', 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.
Modified: django/trunk/tests/regressiontests/defaultfilters/tests.py
===================================================================
--- django/trunk/tests/regressiontests/defaultfilters/tests.py 2009-04-12
04:15:45 UTC (rev 10542)
+++ django/trunk/tests/regressiontests/defaultfilters/tests.py 2009-04-12
04:55:41 UTC (rev 10543)
@@ -83,6 +83,9 @@
>>> 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 & Jill & Jeroboam'
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---