Menu

#45 Incorrect parsing of strings with null characters (\u0000)

0.5.0
closed-fixed
nobody
Value (7)
5
2015-03-06
2012-05-10
Anonymous
No

The internal representation of JSON strings is as C-style null-terminated strings, and when a JSON string containing a null character, such as "\u0000\u0001" is put into this internal representation, no checking is done as to whether there are null characters. Thus, all JSON strings read by jsoncpp are quietly truncated at the first null character. This is particularly baffling to the user when null is the first character in a long string and jsoncpp is returning the empty string. This is clearly a JSON compliance bug.

Discussion

  • wojciech

    wojciech - 2012-07-06

    That is right Peter I have the same problem. Although I am not sure where exactly the problem occurs - during parsing Json::Reade::parse() or during representation Json::Value::asString() ?

     
  • Stefan Wehner

    Stefan Wehner - 2013-04-05

    We've also come across this problem lately and I've added the patch 3610134 for 0.6.0-rc2 which should add support for \0 characters.

    https://sourceforge.net/tracker/?func=detail&aid=3610134&group_id=144446&atid=758828

    If you want to test/try it, I'm sure the feedback will be appreciated!

     
  • Christopher Dunn

    UTF-8 with embedded zeroes is now supported at: https://github.com/open-source-parsers/jsoncpp/

     
  • Christopher Dunn

    • status: open --> closed-fixed
    • Group: --> 0.5.0
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.