blackberry / BB10-WebWorks-Framework

The BB10 WebWorks Framework is packaged within an application BAR file to run on a BB10 device (or simulator)
60 stars 34 forks source link

Requesting contacts from PIM throwing JSON Parse Error #682

Open Cisneiros opened 10 years ago

Cisneiros commented 10 years ago

When requesting contacts from PIM using the "find" method, on some phones, it throws a SyntaxError: JSON Parse Error: Expected '}' (thrown by WebWorks itself, it does not even call the onFindError callback).

I've seen a similar error with extensions (issue #124), which throws the same error, and maybe this is related. I think it is some special character being returned by the Native extension that is causing this, but I cannot be sure, as I don't know which specific contact is causing this to happen (the phones it happen have hundreds or thousands of contacts).

jeffheifetz commented 10 years ago

Can you confirm what version of WebWorks you are using?

Cisneiros commented 10 years ago

Sorry for the Delay. I'm using the most recent one. 1.0.4.11. I've narrowed down which characters cause problems (by creating contacts with each unicode character until I got an error trying to fetch them).

The problem is if a contact's field contains a double-quote or a backslash. This is probably an escaping issue, as it can render the JSON invalid. For example, if the contact's name is Marry " Jane, the JSON would be

{
    first_name: "Mary " Jane",
    ...
}

The same happens when the name ends on a backslash, as it escapes the last double-quote. I tried to solve this by editing the extension, but I didn't manage to do it.

Cisneiros commented 10 years ago

Confirming my expectations, this is what happens when I inject some arbitrary JSON on the Contact Name:

Editing contact:

img_00002278

The contact on the Address Book:

img_00002279

My WebWorks app that requests the contact and prints "givenName + familyName":

img_00002280

Cisneiros commented 10 years ago

@jeffheifetz Any updates on this? :)