Uploaded image for project: 'XWiki Commons'
  1. XWiki Commons
  2. XCOMMONS-1836

Output of JSON containing backslashes leads to broken JSON

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: 11.10.2
    • Fix Version/s: None
    • Component/s: Velocity
    • Labels:
      None
    • Difficulty:
      Unknown
    • Similar issues:

      Description

      Reproduction steps:

      • Create a page with the following content:
        {{velocity}}
        #if($request.outputSyntax == "plain")
          $response.setContentType('application/json')
        #end
        $jsontool.serialize("Something with \ backslash")
        {{/velocity}}
        
      • Open the page in get mode with ?outputSyntax=plain

      Expected result:

      • You see "Something with \ backslash" in get mode and the obtained JSON is valid

      Obtained result:

      • Instead of the "\" you see a line return, and the JSON is marked as invalid because of it

      Note: I tried using "\" and

      \\ 
      

      without any change on the resulted JSON validity.

        Attachments

          Activity

            People

            Assignee:
            surli Simon Urli
            Reporter:
            surli Simon Urli
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Date of First Response: