Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4041

JSONValidationInterceptor and quotes in message

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.3.14
    • 2.3.20
    • Plugin - JSON
    • None

    Description

      Hello,
      There is a problem with org.apache.struts2.json.JSONValidationInterceptor
      This class is using StringEscapeUtils.escapeEcmaScript(String) to escape the generated JSON string.
      The problem is that StringEscapeUtils.escapeEcmaScript escapes the apostrophes. Some JSON implementations accept the escaped apostrophes but some other don't and they are not able to parse the JSON.
      I think there should be at least an option to disable apostrophe escaping. But as I believe escaping apostrophe is not part of the JSON specifications, the best would be to not allow apostrophe escaping.
      As an example, here is a JSON string generated by the JSON plugin :

      {
          "fieldErrors": {
              "password": [
                  "Password isn\'t correct"
              ]
          }
      }
      

      If you test it on http://jsonlint.com/, it says the syntax is incorrect.

      Thanks.

      See the original question on the Struts User ML

      Attachments

        1. string.gif
          17 kB
          Maurizio Cucchiara
        2. WW-4041-test.patch
          3 kB
          Maurizio Cucchiara

        Issue Links

          Activity

            People

              lukaszlenart Lukasz Lenart
              mael_lg mael le guével
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: