Subject: | Unicode line and paragraph separators (\u2028 and \u2029) are not correctly JavaScript escaped |
Date: | Tue, 13 Mar 2012 16:48:22 -0700 |
To: | bug-JSON [...] rt.cpan.org |
From: | Joel Stevenson <jstevenson [...] bepress.com> |
Version: JSON-2.53
Perl: 5.10.1
Platform: Linux jstevenson1.bepress.com 2.6.26-2-xen-amd64 #1 SMP Wed
Jan 13 00:12:41 UTC 2010 x86_64 GNU/Linux
JSON::PP is passing these characters through to the final JSON string
but should be converting them to \u escapes.
perl -MJSON::PP -E 'say JSON::PP::encode_json( [ "line sep here>\x{2028}<" ] )'
["line sep here>
<"]
Should be:
["line sep here>\u2028<"]
Looks like the ECMA 262 spec says (section 7.8.4) that line separator
and paragraph separator characters may not appear un-escaped in a
string literal. IE doesn't seem to care but FF and Chrome do and will
throw an "unterminated string literal" error upon encountering them in
a string literal.