Closed GoogleCodeExporter closed 8 years ago
I've narrowed it down a bit, to the following JSON:
{
"html": "I.G.G. (Internet Gaming Gate) has announced a new 3D Hellenistic MMORPG called Gods War √جºàhttp:\/\/gw.igg.com√جºâ."
}
The issue appears to be the strange five-byte sequence that is supposed to
represent a quote of some form. JSONLint is able to parse the structure as
valid JSON.
Original comment by josh.petrie
on 24 Oct 2010 at 7:09
I *think* the strange sequence is invalid UTF8 (which may example why [NSString
initWithBytes...] fails and returns nil inside
scanNotQuoteCharactersIntoString), but I'm not sure how to confirm that, nor
what could be done to prevent this from crashing (the JSON is from a web
service not under my control).
Original comment by josh.petrie
on 24 Oct 2010 at 7:44
I've managed to avoid the problem described here by sanitizing all the input to
TouchJSON. It would be more optimal of TouchJSON could do that itself when it
detects an error (for example when [NSString initWithBytes] returns nil), but I
can see how this may not be something that's in-line with the desired direction
of the library.
So I suppose you could consider this more of a feature request at this point
(implementing automatic replacement of invalid UTF8)
Original comment by josh.petrie
on 27 Oct 2010 at 3:18
(I can provide the code I used to sanitize the input, but I wouldn't know for
sure if its 100% correct or where the appropriate place to patch TouchJSON to
use it would be).
Original comment by josh.petrie
on 27 Oct 2010 at 3:19
Bug moved to github:
http://github.com/schwa/TouchJSON/issues/issue/12
Original comment by jwight
on 1 Nov 2010 at 6:48
Original comment by jwight
on 1 Nov 2010 at 7:31
Original issue reported on code.google.com by
josh.petrie
on 24 Oct 2010 at 4:28Attachments: