[Mono-bugs] [Bug 660705] New: JsonValue.ToString() incorrectly escapes strings with pairs of quotes embedded.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Dec 20 20:56:02 EST 2010



           Summary: JsonValue.ToString() incorrectly escapes strings with
                    pairs of quotes embedded.
    Classification: Mono
           Product: Mono: Class Libraries
           Version: unspecified
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: enagel at nageltech.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)
AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10

JsonValue.ToString() doesn't add a backslash to the second quote when two
quotes are next to each other in a string literal.

Reproducible: Always

Steps to Reproduce:
Run the following test code:

                JsonObject json1 = new JsonObject();
                json1["Val"] = "Empty quotes (\"\") are evil!";

                string str = json1.ToString();

                Console.WriteLine("str = {0}", str);

                JsonValue json2 = JsonValue.Parse(str);    // crash

                Console.WriteLine("Test passed!");
            catch(Exception ex)
                Console.WriteLine("{0}({1})", ex.GetType().Name, ex.Message);
                Console.WriteLine("{0}", ex.StackTrace);

Actual Results:  
str = {"Val": "Empty quotes (\"") are evil!"}
ArgumentException(Invalid JSON string literal format. At line 1, column 28)
  at System.Json.JsonReader.ReadStringLiteral () [0x0000d] in
  at System.Json.JsonReader.ReadCore () [0x00114] in
  at System.Json.JsonReader.Read () [0x00000] in
  at System.Json.JsonValue.Load (System.IO.TextReader textReader) [0x00011] in
  at System.Json.JsonValue.Parse (System.String jsonString) [0x00011] in

Expected Results:  
The system should be able to correctly encode embedded escapes.  While the
exception happens when deserializing here, the bug is caused because it wasn't
serialized successfully in the first place (see the first line of "Actual

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list