Page MenuHomePhabricator

invalid HTML: invalid width attribute value
Closed, InvalidPublic


Author: peter.moulder

Description: has invalid HTML ‘<th width="37px">’: th/td's width attribute ( and hence should be either a plain integer ("37") or a percentage, not a number with units like the CSS width property.

The corresponding wiki markup seems to be simply ‘{{sisterlinks}}’.

I don't know how {{sisterlinks}} is implemented, but I'd guess that the problem is the same as for tables generally when a width param is given.

Looking at the Help pages for tables, I see that even one of the examples in (and its master copy has the same problem: specifying width="100pt" among the parameters produces HTML with ‘<td width="100pt">’.

The fix is that a wiki param of ‘width="50px"’ should get converted to ‘width="50"’, while ‘width="100pt"’ should either get converted to a corresponding declaration in the style attribute (‘style="width: 100pt;"’) or be forbidden (getting the user to choose whether to use px or use a style element) or possibly get converted to px at a rate of 96px/in for screen and 128px/in for print (these numbers based on

Whereas currently, the width param seems to be passed through verbatim with no checking, so one can have width="random garbage" in the HTML.

Wiki's shouldn't be able to pass arbitrary text into HTML, for the reasons given at : it may allow triggering bugs in HTML user agents that expect valid HTML.

Version: unspecified
Severity: normal



Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:58 PM
bzimport set Reference to bz11738.
bzimport added a subscriber: Unknown Object (MLST).

peter.moulder wrote:

If (as suggests) it's considered valuable for the width specification to be honoured even on user agents that ignore/mishandle inline CSS styling, then one could use the fact that the style attribute takes precedence over presentation attributes (for compliant browsers), and give both a width attribute and a style attribute with a width property even if this involves converting pt to px.

A related issue is that the bgcolor attribute is being passed through to HTML with invalid values. E.g. one page (Saffron) has bgcolor=lightgreen, whereas the bgcolor attribute is restricted to 6-digit hexadecimal values and the 16 basic colors (

(In fact even CSS2.1's background-color property accepts only 17 color names (adding orange:, unlike SVG1.1 which accepts the full X11 set of color names (

Ideal behaviour would be to continue to accept bgcolor=lightgreen and other X11/SVG color names as wiki markup, but to change it to bgcolor="#90ee90" in the generated HTML.

Whether or not this extension is implemented, unrecognized color names should not be passed through to HTML: the human editor should be made aware of the issue so that they can change to a recognized color form rather than have the invalid color recognized by some browsers and not by others, and also so as to reduce the opportunity to exploit bugs in user agents by giving invalid attribute values.

Changing Product: Wikimedia → Mediawiki
Changing Component: WikiBugs → user Interface
Reason: The wikibugs component is designed for the I.R.C. bot.

TheDJ claimed this task.
TheDJ added a subscriber: TheDJ.

Sisterlinks has been fixed a long while ago, as has the en.wp documentation (both en.wp issues that did not belong in the bugtracker.

These attributes have also been removed from HTML since, and part of that is tracked in T68413.