allen58992008 / touchcode

Automatically exported from code.google.com/p/touchcode
0 stars 0 forks source link

Deserializing a non-UT8 string causes a crash #69

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

NSData *theData = [@"{'will_crash':'¢'}"
dataUsingEncoding:NSISOLatin1StringEncoding];
NSDictionary *parsedData = [[CJSONDeserializer deserializer]
deserializeAsDictionary:theData error:nil];

What is the expected output? What do you see instead?

parsedData should be nil instead of crashing.

What version of the product are you using? On what operating system?

May 2009 (latest).

Please provide any additional information below.

The crash actually takes place in CJSONScanner's
scanJSONStringConstant:error:.  [self
scanNotQuoteCharactersIntoString:&theStringChunk] causes &theStringChunk to
be nil.  The next line, [theString appendString:theStringChunk], then crashes.

Original issue reported on code.google.com by deanbro...@gmail.com on 10 Dec 2009 at 10:42

GoogleCodeExporter commented 8 years ago
Please only decode UTF-8 strings. The default encoding (according to RFC4627) 
is UTF-8 anyhow.

Original comment by jwight on 19 Mar 2010 at 12:22

GoogleCodeExporter commented 8 years ago
Unfortunately touchcode crashes on malformed UTF-8 as well. As a client I can't 
control well-formedness. I'm 
currently looking for a JSON parser that does't unceremoniously crash given bad 
character codes. I'd rather have 
one invalid key or value than nothing at all.

Original comment by nuthatch on 2 Apr 2010 at 9:48