Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
17.10.14, 18.8.0
-
None
-
Unknown
-
Description
A macro parameter of type boolean or int accepts any value. A value that does not convert is replaced without an error: an unknown boolean becomes false and an invalid number becomes 0. The macro then runs with a value the user never typed, and nothing tells them the value was wrong.
Steps to reproduce
- Edit a page with the wiki editor.
- Add {{toc numbered="maybe"/}} and {{toc depth="abc"/}} on a page with headings.
- Save and view the page.
Expected
Both macros fail with a message saying that the value of the parameter cannot be converted.
Actual
- The first table of contents renders unnumbered, as if numbered was false.
- The second fails with "Failed to validate bean: [must be greater than or equal to 1]": abc was converted to 0, and only the @Min(1) constraint stopped it.
The WYSIWYG usability audit of the macros found the same on most of the 67 macros reviewed, for example wiki="abc" on the HTML macro, status="maybe" on the message macros, readOnly="maybe" on documentTree, which makes the tree editable, and count="abc" on notifications, which loops forever, see XWIKI-25412.
Lead
ConvertUtilsConverter registers the throwing BeanUtils converters in initialize(), on BeanUtilsBean.getInstance(), so that a failed conversion raises an error rather than returning a default value. That instance is kept per context class loader, so the conversions run under another context class loader may use the lenient default converters. The tests of ConvertUtilsConverter do not cover an invalid boolean or number.
Attachments
Issue Links
- blocks
-
XWIKI-25578 Report a missing or unknown target in the errors of the include, display, context, uiextensions and wikimacroparameter macros
-
- Open
-
-
XWIKI-25579 Report a missing or invalid jar in the errors of the script macros
-
- Open
-
-
XWIKI-25580 Report the invalid values of the documents, documentTree and tree macros instead of an empty result
-
- Open
-
-
XWIKI-25581 Report the invalid values of the attachmentGalleryPicker and attachmentSelector macros instead of showing nothing
-
- Open
-
-
XWIKI-25582 Refuse the invalid values of the cache, code, container, gallery and menu macros instead of ignoring them
-
- Open
-
-
XWIKI-25583 Report a missing user or icon in the displayIcon, mention and useravatar macros instead of falling back silently
-
- Open
-
- is related to
-
XRENDERING-828 Provide an image picker for the image parameter of the box and message macros
-
- Open
-
-
XWIKI-25457 Provide a field for CSS values in the Edit Macro dialog
-
- Open
-
- relates to
-
XWIKI-25412 The notifications loop forever when the requested count is 0 or not a number
-
- Closed
-
-
XRENDERING-823 The error shown for an invalid macro parameter doesn't name the parameter or the expected value
-
- Open
-
-
XWIKI-25182 Numeric macro parameters accept any text in the Edit Macro dialog
-
- Open
-
-
XWIKI-25197 Allow wiki macro parameters to declare a range or a format for their value
-
- Open
-
-
XWIKI-25287 The Edit Macro dialog doesn't enforce the constraints declared on the parameters of Java macros
-
- Open
-