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

Wiki creation logs containing backslashes are breaking JSON serialization

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 11.10.10, 12.6.2, 12.8
    • Fix Version/s: 12.6.3, 12.9-rc-1, 11.10.11
    • Component/s: Job
    • Labels:
      None
    • Environment:
      windows
    • Difficulty:
      Unknown
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: