mmattozzi / cocoa-rest-client

A free, native Apple macOS app for testing HTTP/REST endpoints
http://mmattozzi.github.io/cocoa-rest-client/
Other
2.35k stars 206 forks source link

100% crashed when get a json #135

Closed huabin closed 6 years ago

huabin commented 6 years ago

Cocoa Rest Client Version: 1.4.3 (26)

macOS Version: 10.13.2

reproduce:

  1. open cocoarestclient

  2. input https://chainz.cryptoid.info/explorer/api.dws?q=summary

  3. method GET

  4. submit, and you will get the crash.

mmattozzi commented 6 years ago

Well, that's interesting... looks like it's coming from the JSON library I've used, json-framework.

2017-11-28 08:36:00.514323-0500 CocoaRestClient[61562:43681851] *** Assertion failure in -[SBJson4Parser parserFound:isValue:], /Users/mmattozzi/code/cocoa-rest-client/Pods/SBJson/src/main/objc/SBJson4Parser.m:151
2017-11-28 08:36:00.516186-0500 CocoaRestClient[61562:43681851] [General] An uncaught exception was raised
2017-11-28 08:36:00.516210-0500 CocoaRestClient[61562:43681851] [General] Invalid parameter not satisfying: obj

I'll have to poke around on this a little bit.

mmattozzi commented 6 years ago

The data returned by that URL appears to contain an invalid character:

"PoW" : "Scrypt² PoWT",

In theory, JSON should be either UTF-8 or UTF-16, but that character doesn't appear to be either -- it might be ISO-8859. The JSON library I'm using for pretty printing doesn't even support UTF-16 (see: https://github.com/stig/json-framework/issues/115) so it seems like it has a tight coupling on UTF-8... and in fact the line of code that is crashing the entire program is trying to create a new String assuming a UTF8 encoding while tokenizing that character.

Long story short... I think at best I will have to catch the error to prevent the crash but then display the text without pretty printing.

mmattozzi commented 6 years ago

Fixed in Version 1.4.4