Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stringify should "/" not excape with prefix "\" in strings #38

Open
kh0815 opened this issue Jun 13, 2018 · 1 comment
Open

Stringify should "/" not excape with prefix "\" in strings #38

kh0815 opened this issue Jun 13, 2018 · 1 comment

Comments

@kh0815
Copy link

kh0815 commented Jun 13, 2018

In my opinion in std::wstring JSONValue::StringifyString(const std::wstring &str)

Line 879:
if (chr == L'"' || chr == L'\' || chr == L'/')
should be just:
if (chr == L'"' || chr == L'\')

I found in https://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf in section 24.5.2 "JSON.stringify" NOTE 3 no special rule for "/".

The link in the comment above the JSONValue::StringifyString function is outdated and the referenced section "Section 15.12.3." does not exists in my document.

@MJPA
Copy link
Owner

MJPA commented Jun 15, 2018

Good question... the comment in the code should probably reference https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf - as that's what was followed - the tab character isn't escaped as most JSON parsers didn't escape it at the time either.

The ECMA-262 is the ECMAScript specification which is slightly different but should be more accepting than ECMA-404.

https://jsonlint.com & browsers accept both \/ and / (as they should) but don't escape when stringifying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants