Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-7496

Parsing Bug in org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter: in-string "{"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1.7, 3.1.12
    • 3.1.13, 3.2.0
    • JAX-RS
    • None
    • java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

    • Unknown

    Description

      Hello,

      We have found incorrect parsing of "{" within JSON strings. It seems like the parser searches for "

      {" and "}

      " regardless of string boundary.

      A reproduction program is attached, using latest 3.1.12 version.

      Thanks!

      REPRODUCTION

      import org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter;
      
      public class JsonMapReaderNotWorking {
      	
      	public static void main(String args[]) throws Exception
      	{
      		JsonMapObjectReaderWriter jsonMapObjectReaderWriter = new JsonMapObjectReaderWriter();
      		String s = "{\"x\":{\"y\":\"{\"}}";
      		System.out.println(s);
      		jsonMapObjectReaderWriter.fromJson(s);
      	}
      }
      

      RESULT

      	{"x":{"y":"{"}}
      	Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -6
      		at java.lang.String.substring(String.java:1967)
      		at org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter.readJsonObjectAsSettable(JsonMapObjectReaderWriter.java:189)
      		at org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter.fromJson(JsonMapObjectReaderWriter.java:162)
      		at JsonMapReaderNotWorking.main(JsonMapReaderNotWorking.java:13)
      

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            alonbl Alon Bar-Lev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: