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

Exception when a valid JSON file containing U+2028 is required #1086

Closed
Macil opened this issue Jan 22, 2015 · 2 comments
Closed

Exception when a valid JSON file containing U+2028 is required #1086

Macil opened this issue Jan 22, 2015 · 2 comments

Comments

@Macil
Copy link

Macil commented Jan 22, 2015

If you try to use Browserify to build a javascript bundle that calls require() to include a JSON file that contains a U+2028 (line separator) or U+2029 (paragraph separator) character, then Browserify throws an exception.

U+2028 and U+2029 characters are both valid inside strings in JSON, but not in javascript. JSON is not perfectly a Javascript subset. When Browserify transforms JSON files to javascript by prepending module.exports=, it also needs to transform all U+2028/9 characters (which would only be present inside strings) to \u2028 and \u2029. A well-placed .replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029'); should do the trick.

Here's an example repo showing the issue: https://github.com/AgentME/br-json-test

@Macil
Copy link
Author

Macil commented May 11, 2015

Fixed by #1211.

@Macil Macil closed this as completed May 11, 2015
@jmm
Copy link
Collaborator

jmm commented May 11, 2015

@agentme I just wanted to acknowledge this and say thank you for the report!

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

No branches or pull requests

2 participants