[Yaml-core] Fwd: Hash style comments

Andrea Giammarchi andrea.giammarchi at gmail.com
Fri Aug 10 08:01:54 PDT 2012


just in case, since mentioned here ...

https://github.com/WebReflection/JSONH#javascript-and-native-json-escape-problems

to make stringified JSON safer so that

JSONH.stringify(data).replace(
    /\u2028|\u2029/g,
    function (m) {
        return "\\u202" + (m === "\u2028" ? "8" : "9");
    })

cheers

On Thu, Aug 9, 2012 at 2:18 PM, Trans <transfire at gmail.com> wrote:

> From: Oren Ben-Kiki <oren at ben-kiki.org>
> Date: Thu, Aug 9, 2012 at 3:21 AM
> Subject: Re: [Yaml-core] Fwd: Hash style comments
> To: Trans <transfire at gmail.com>
> Cc: Yaml-core <yaml-core at lists.sourceforge.net>
>
> >
> > Pedantry alert: someone noticed that JSON does not treat U+2028 and
> > U+2029 (line terminators in JS) as space characters. So these can
> > occur (unescaped) in JSON string literals, but not in JS string
> > literals. Therefore JSON accepts sentences not legal in JS:
> >
> > js> JSON.parse('{"a":"\u2028","b":2}')
> > ({a:"\u2028", b:2})
> > js> eval('({"a":"\u2028","b":2})')
> > typein:11: SyntaxError: unterminated string literal:
> > typein:11: ({"a":"(
> > typein:11: ......^
> >
> > Does YAML treat U+2028 and U+2029 the same as JSON does, or as JS does?
>
> YAML doesn't do any special treatment of characters above 0xFF;  it
> assumes all valid Unicode code points above 0xFF are
> non-break-non-white "printable" characters and allows them to be used
> most anywhere.
>
> We used to treat NEL, LS, PS as line breaks but we gave it up to
> maintain JSON compatibility. We are OK as long as YAML is a superset
> of JSON, which seems to be the case.
>
> Oren.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120810/14be244d/attachment.html>


More information about the es-discuss mailing list