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

Autocompletion for Spaces and Pages turns ampersands into &

    XMLWordPrintable

Details

    • Easy
    • N/A
    • N/A

    Description

      The autocompletion for spaces and pages inserts an & for any & in a selected space / page name

      Steps to Reproduce:

      • go to any page, e.g. Sandbox.Webhome
      • choose "Add" -> "Page" and type in "Foo & Bar" as page name and click on "Create"
      • on the following page click "Save & View" to really create the page in the DB
      • click on "edit" to go back to the edit view
      • click on the "edit parent" icon
      • a text field for the parent appears with contents 'Sandbox.WebHome'
      • Remove the "WebHome part and type in 'Foo' and wait a moment for the autocompletion results to appear
      • When the results appear, click on the 'Sandbox.Foo & Bar'

      Expected Result: "Parent" field should be filled with 'Sandbox.Foo & Bar'
      Actual Result: "Parent" field is filled with 'Sandbox.Foo & Bar'

      (The is another quirk here that you can set a page to the parent of itself, with consequences not clear to me, but that is maybe a separate issue.)

      The cause of the problem is that the JavaScript code reads the contents of the Autocompletion as (unescaped) HTML, but inserts them into the text field as the 'value' attribute, where it automatically gets HTML encoded.

      One possibility to fix this is in the file xwiki-platform-core/xwiki-platform-web/src/main/webapp/resources/uicomponents/suggest/suggest.js
      where around line 835 one has

      'value': this.iHighlighted.down(".suggestValue").innerHTML,
      

      As this reads the content as HTML, a (clumsy) fix is to read it as text instead, e.g.

      'value': this.iHighlighted.down(".suggestValue").textContent || this.iHighlighted.down(".suggestValue").innerText,
      

      Mabye there is a better way to get around the browser incompatibilities of getting the text content of a node.

      Attachments

        Activity

          People

            mflorea Marius Dumitru Florea
            camil7 Clemens Robbenhaar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: