Details
Description
These macros display a user or an icon named by a parameter. When the user or the icon does not exist, they silently fall back to a default, or render nothing, so the page shows a wrong result and the user is never told that the name is wrong.
The macros to change, with the file where most of the fix is done:
- displayIcon: DisplayIconMacro.java.
- mention: defined in its wiki macro, MentionsMacro.xml.
- useravatar: UserAvatarMacro.java.
The main problems:
- displayIcon: an unknown icon name, or a Font Awesome name like fa-home, renders an empty paragraph; an unknown icon set, or one in the wrong case, silently gives the icon of the default theme, and nothing at all with fallback="false".
- mention: a reference to a user that does not exist, a display name or a page renders a link to a missing page, and an empty reference mentions the current space.
- useravatar: a username that is not a user gives the default avatar, and a width or height like "50%" or "40px" gives width="0", so the avatar disappears.
The fix is to check that the user or the icon exists and to show an error naming the parameter when it does not, at least in the editor.
Depends on
- XCOMMONS-3847, which refuses the boolean and number values that do not convert.
- XRENDERING-823, which makes the error of an invalid parameter name the parameter and the expected value.
KOs covered
| Macro | Criterion | Problem |
|---|---|---|
| displayIcon | E2 errors | {{displayIcon name="nosuchicon"/}}, name="fa-home" and name="" render an empty paragraph, iconSet="NoSuchSet" and iconSet="silk" silently give the Silk icon, and fallback="false" then renders nothing, all with no message. Partly covered, see below. |
| mention | E2 errors | reference="XWiki.NoSuchUser" and reference="John Doe" render a link to a page that does not exist, reference="Main.WebHome" mentions a page, reference="" renders the current space, and anchor="my anchor" gives an invalid HTML id. Partly covered, see below. |
| useravatar | E2 errors | width="abc", "50%" or "40px" gives width="0", so the avatar disappears, negative sizes are output as is, and a username that is not a user silently gives the default avatar. Partly covered, see below. |
Impact found on macro fluidity
These 3 KOs come from the WYSIWYG usability audit of the macros, under the criterion E2 errors of its usability criteria, which asks that an invalid parameter value produces a message that says what is wrong and how to fix it, not a stack trace. The page of each macro, linked in the table, has the full notes and the steps to reproduce.
Each of these KOs is only partly covered here, for the problems specific to the macro. The same KOs also report invalid values that the macro system handles for every macro: XCOMMONS-3847 refuses the booleans and numbers that do not convert, and XRENDERING-823 makes the error name the parameter and the expected value. The type and style of mention are covered by XWIKI-25504.
Attachments
Issue Links
- depends on
-
XCOMMONS-3847 Invalid boolean and number values of a bean property are silently converted instead of failing
-
- Open
-
-
XRENDERING-823 The error shown for an invalid macro parameter doesn't name the parameter or the expected value
-
- Open
-