We are developing an app with a RESTful JSON Api and trigger.io (v2.1.6 of trigger.io and 2.5 of the request module).
Some data contains user generated content and we got bitten hard by the fact that this content might contain \u2028 or \u2029 characters. (which leads the json response to not being valid JS)
Details:
“SyntaxError: Unexpected EOF” when evaluating JavaScript in iOS UIWebView
And http://timelessrepo.com/json-isnt-a-javascript-subset
This triggers a window.onError "with SyntaxError: Unexpected EOF" without any stack trace on iOS (verified on iOS7.1 on device as well as in simulator).
Here is an example JSON containing a \u2028 char in the middle of a string "foo\u2028bar".
The code we use to trigger the problem is the following - you need to point the url to the u2028.json on a server and call this function.
trybreakJson: function(){
forge.request.ajax({
type: "GET",
url: ,
success: function(data, headers) {
console.log(data);
console.log("GOT DATA");
alert(data);
alert('Response headers: ' + JSON.stringify(headers));
},
error: function(error) {
alert('Failed to update x: '+error.message);
}
});
},
I am trying to figure out where the JSON might be incorrectly evaluated but i only found references to JSON.parse in all.js (which should be fine with these characters).
Where is this error occurring? I looked at the Request module and it seems fine. Any takers?