You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When incoming JSON to be parsed contains the character sequence \u0000, YAML blows up. \u0000 converts to \x00 with unescape just fine, but YAML chokes. Basically, this is because end-of-string is considered to be wherever \u0000 was.
The same issue does not arise if \x00 was in the initial string to be JSON.parsed.
Fix/pull-request forthcoming.
The text was updated successfully, but these errors were encountered:
Here is a quick monkey patch that you can use to get around this problem. By no means is this presented as a permanent fix.
All it does is deletes any \u0000 control characters from the string before it gets converted to yaml.
Not entirely elegant but it does the job...
#### This is a monkey patch that fix a bug with how Crack/YAML parses the unicode control character \u0000.## To get around the Invalid JSON string error, we simply remove these from the string##moduleCrackclassJSONdefself.parse(json)YAML.load(unescape(convert_json_to_yaml(json.gsub(/\\[u|U]0000/,""))))rescueArgumentError=>eraiseParseError,"Invalid JSON string"endendend
You can see my -- as yet unmerged -- pull request that fixes this here. If you're using Crack through HTTParty, you can get around this by using a different JSON parser besides Crack. See discussion here.
When incoming JSON to be parsed contains the character sequence
\u0000
, YAML blows up.\u0000
converts to\x00
withunescape
just fine, but YAML chokes. Basically, this is because end-of-string is considered to be wherever\u0000
was.The same issue does not arise if
\x00
was in the initial string to beJSON.parsed
.Fix/pull-request forthcoming.
The text was updated successfully, but these errors were encountered: