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

The macro editor doesn't quote the values of a multi-value parameter that contain a separator

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • 18.10.0-rc-1
    • 18.9.0
    • WYSIWYG Editor
    • None
    • Unknown

    Description

      When a macro parameter is edited with a field that holds several values, such as the multi location picker added by XWIKI-24636, the macro editor writes the parameter by joining the values with a comma, and reads it back by splitting it on commas. Values are never quoted. A value containing a comma or a space is therefore split into several values once the macro runs, since the conversion of a List<...> parameter splits on commas and spaces unless the value is quoted.

      Steps to reproduce:

      1. Create a wiki macro with a spaces parameter of type java.util.List<org.xwiki.model.reference.SpaceReference> whose content displays each location on its own line.
      2. Create the locations My Space and Space.My, Page.
      3. Insert the macro in a page with the WYSIWYG editor and pick both locations in the spaces field.
      4. Save and look at the page source and at the macro output.

      EXPECTED RESULTS: The macro gets 2 locations, My Space and Space.My, Page. The source holds them quoted, e.g. spaces="\"My Space\",\"Space.My, Page\"", and opening the macro again shows the 2 locations.

      ACTUAL RESULTS: The source holds spaces="My Space,Space.My, Page", which the macro gets as 4 locations: My, Space, Space.My and Page. Opening the macro again shows 3 values: My Space, Space.My and Page.

      The same happens to an existing quoted value: spaces="'Space.My, Page'" opens as 'Space.My and Page'.

      Suggested fix: when joining, put double quotes around each value containing a comma, a whitespace or a quote, escaping }} and {{" inside, which is the syntax AbstractCollectionConverter already parses. When reading, use a quote-aware split instead of split(','). Values without such characters are written exactly as today.

      Attachments

        Issue Links

          Activity

            People

              Lucas C Charpentier Lucas
              Lucas C Charpentier Lucas
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: