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

JSON.parse(null) fails on htc adroid 2.3.5 #1401

Closed
raix opened this issue Sep 5, 2013 · 4 comments
Closed

JSON.parse(null) fails on htc adroid 2.3.5 #1401

raix opened this issue Sep 5, 2013 · 4 comments

Comments

@raix
Copy link
Contributor

@raix raix commented Sep 5, 2013

The native webkit JSON.parse fails input values of null - resulting in a black screen. Can anybody confirm? (It seems very version specific)

This fixes the issue, currently I aplied it in json2.js - but I'm thinking if the json2.js is replaced by a new version the fix would be lost - it might be better to add this in the json_native?

if (typeof JSON !== 'object') {
    JSON = {};
} else {
    JSON.originalParse = JSON.parse;
    JSON.parse = function(text) {
        // Some android 2.3.5 browsers fail when JSON.parse(null);
        return JSON.originalParse(String(text));
    };
}
@glasser
Copy link
Member

@glasser glasser commented Sep 5, 2013

Why are you passing null to JSON.parse? Does Meteor ever do this?

@raix
Copy link
Contributor Author

@raix raix commented Sep 5, 2013

I spent a day debugging this on an android, it's close to hell, http://code.google.com/p/android/issues/detail?id=11973
I'm filing this as an issue with the builtin json, i dont think pasing null to json.parse should break the app?

@awwx
Copy link
Contributor

@awwx awwx commented Sep 5, 2013

It would be a good idea for EJSON.parse to throw an exception if its argument isn't a string.

https://github.com/meteor/meteor/blob/release/0.6.5.1/packages/ejson/ejson.js#L214

@raix
Copy link
Contributor Author

@raix raix commented Sep 5, 2013

Yep, maybe throwing an error instead, the null as a parametre is not intended but it happend in my case passing stuff from localstorage getitem i think. But on android 2.3.5 this breaks the app and you get a black screen and error in logcat speaking about illegal access. So better options for debugging would be Nice since it could have been a package or whatever setting null.

awwx added a commit to awwx/meteor that referenced this issue Sep 5, 2013
Some Android browser versions of JSON.parse can crash when passed null
(https://code.google.com/p/android/issues/detail?id=11973), so it's
better not to pass on a non-string argument to JSON.parse.

Thanks to @raix for raising the issue in meteor#1401.
glasser added a commit that referenced this issue Sep 12, 2013
Some Android browser versions of JSON.parse can crash when passed null
(https://code.google.com/p/android/issues/detail?id=11973), so it's
better not to pass on a non-string argument to JSON.parse.

Thanks to @raix for raising the issue in #1401.
@glasser glasser closed this Sep 12, 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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants