Page MenuHomePhabricator

Sidebar can generate invalid HTML
Closed, ResolvedPublic

Description

Author: michaeldaly

Description:
If one enters a heading in Mediawiki:Sidebar with an embedded blank, the resulting HTML is not valid.

Example:

Mediawiki:Sidebar contains:

  • recent changes
    • recentchanges-url|recentchanges

Output is:

<div class='portlet' id='p-recent changes'>

The blank in the id is not valid.

At a minimum, in various /skins/skinname.php files, the second line of the following code should be changed from:

<?php foreach ($this->data['sidebar'] as $bar => $cont) { ?>
  <div class='portlet' id='p-<?php echo htmlspecialchars($bar); ?>'>

to:

<?php foreach ($this->data['sidebar'] as $bar => $cont) { ?>
  <div class='portlet' id='p-<?php echo str_replace( ' ', '_', htmlspecialchars($bar) ); ?>'>

It may be necessary, in general, to strip out or convert other invalid characters/symbols in the heading string.

Note if this editing is done in /includes/Skin.php (where the data is constructed), it will result in the modified text being displayed on the wiki page. Modifying it in the /skins/skinname.php file(s) preserves the display and only prevents the invalid HTML from being generated.


Version: unspecified
Severity: minor

Details

Reference
bz10009

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:48 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz10009.
bzimport added a subscriber: Unknown Object (MLST).

robchur wrote:

*** This bug has been marked as a duplicate of bug 9338 ***