1

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?

Community
  • 1
  • 1
Richard
  • 69
  • 6
  • Are you able to provide the JSON response in question? Which mobile platform are you experiencing this behavior on: iOS, Android or both? – Clive Seebregts May 13 '14 at 15:25
  • We experience the problem on iOS (verified with iOS 7.1 here). Here is minimal example: [u2028.json](https://www.dropbox.com/s/lobrxluagsae3cv/u2028.json). The sha hash of the file should be e5bf4da7d9759cf174a10c8c556455427c46362d. A simple forge.request.ajax should do the trick. I call the following function: https://gist.github.com/richardkogelnig/f3241683b4134955dd82 . point the url to the u2028.json file on a server. – Richard May 14 '14 at 15:37

0 Answers0