On Thu, Feb 4, 2016 at 11:04 AM, Dominique Devienne <ddevienne at gmail.com>
wrote:

> On Thu, Feb 4, 2016 at 10:43 AM, Eric Grange <zarglu at gmail.com> wrote:
>
>> I have been experimenting with using the json1 extension to generate json
>> sql-side rather than code-side, but I am hitting an issue with the CR & LF
>> characters which are not escaped, which results in json that fails
>> JSON.parse or use as JSONP in browsers. Ideally CR / LF should be encoded
>> as \r and \n respectively.
>>
>> Is it by design or an oversight?
>>
>
> http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf,
> page 4, section 9 String, states:
>
> A string is a sequence of Unicode code points wrapped with quotation marks
> (U+0022). All characters may be placed within the quotation marks except
> for the characters that must be escaped:
> ...
>
> and the control characters U+0000 to U+001F.
>
> There are two-character escape sequence representations of some characters.
> ...
>
> \b represents the backspace character (U+0008).
> \f represents the form feed character (U+000C).
> \n represents the line feed character (U+000A).
> \r represents the carriage return character (U+000D).
> \t represents the character tabulation character (U+0009).
>
>
Those are in the [U+0000 - U+001F] range indeed, so *must* be escaped.
U+0022 and U+005C are explicitly mentioned.
Remains only U+002F, as Stephan mentioned, which is the only that can be
either. --DD

Reply via email to