Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-17908

Wiki creation logs containing backslashes are breaking JSON serialization

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 12.6.3, 12.9-rc-1, 11.10.11
    • 11.10.10, 12.6.2, 12.8
    • Job
    • None
    • windows
    • Unknown
    • N/A
    • N/A

    Description

      Reproduction steps:

      • Setup the servlet engine to support backslashes in URLs
      • On administration > Edition > Name strategies remove "\" from the forbidden characters in page names
      • Create a new empty template wiki and leave it empty
      • Go in the template wiki and create a page with a "\" in its path
      • Create a new wiki from the template you just edited

      Expected result:

      • The wiki creation UI displays that it's successfully created

      Obtained result:

      • The UI get stuck very quickly during the wiki creation

      Old description with other steps:
      We serialize in JSON all the job logs to be able to display them to the users, but apparently when a stack trace concerning a file is outputted in the logs, it break JSON serialization on Windows.
      See the attached JSON.

      Reproduction steps:

      • Create a page with the following snippet:
        {{velocity}}
        #if ($xcontext.action == 'get' && "$!{request.outputSyntax}" == 'plain')
          #set($discard = $response.setContentType('application/json'))
          #set ($message = "File not found exception: C:\MyFile\Somewhere\There")
          #set ($logs = [$escapetool.xml($message)])
          #set($map = {'wikiId':"myId", 'logs':$logs})
          $jsontool.serialize($map)
        #end
        {{/velocity}}
        
      • Call the page with get action and ?outputSyntax=plain, e.g.:
        http://localhost:8080/xwiki/bin/get/Test/?outputSyntax=plain
        

      Expected result:

      • the produced JSON is correct

      Obtained result:

      • the following broken JSON:
        {"wikiId":"myId","logs":["File not found exception: C:
        MyFile
        Somewhere
        There"]}
        

      Edit: actually the snippet is even easier to write:

      {{velocity}}
      #set ($message = "File not found exception: C:\MyFile\Somewhere\There")
      $jsontool.serialize($message)
      {{/velocity}}
      

      shouldn't create any line break.

      Attachments

        Issue Links

          Activity

            People

              surli Simon Urli
              surli Simon Urli
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: