Details
-
Bug
-
Resolution: Unresolved
-
Major
-
18.9.0
-
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:
- 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.
- Create the locations My Space and Space.My, Page.
- Insert the macro in a page with the WYSIWYG editor and pick both locations in the spaces field.
- 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
- blocks
-
XWIKI-25534 Provide a location picker for the location parameters of the tag cloud and documents macros
-
- Open
-
- relates to
-
XWIKI-16958 StaticList default suggest editor with freetext doesn't allow to type a comma
-
- Open
-
-
XWIKI-24636 Create a multi location/space picker
-
- Closed
-