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

Escape of U+2028 and U+2029 in the JSON Encoder #10534

Merged
merged 1 commit into from
May 10, 2013

Conversation

cmaruz
Copy link
Contributor

@cmaruz cmaruz commented May 9, 2013

U+2028 and U+2029 are allowed inside strings in JSON (as all literal
Unicode characters) but JavaScript defines them as newline
seperators. Because no literal newlines are allowed in a string, this
causes a ParseError in the browser. We work around this issue by
replacing them with the escaped version. The resulting JSON is still
valid and can be parsed in the browser.

This commit has been coauthored with Viktor Kelemen @yikulju

References:

U+2028 and U+2029 are allowed inside strings in JSON (as all literal
Unicode characters) but JavaScript defines them as newline
seperators. Because no literal newlines are allowed in a string, this
causes a ParseError in the browser. We work around this issue by
replacing them with the escaped version. The resulting JSON is still
valid and can be parsed in the browser.

This commit has been coauthored with Viktor Kelemen @yikulju
@vanstee
Copy link

vanstee commented May 9, 2013

Might be a duplicate of #10057

rafaelfranca added a commit that referenced this pull request May 10, 2013
Escape of U+2028 and U+2029 in the JSON Encoder

Conflicts:
	activesupport/lib/active_support/json/encoding.rb
@rafaelfranca rafaelfranca merged commit 582b441 into rails:master May 10, 2013
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

Successfully merging this pull request may close these issues.

3 participants