Page MenuHomePhabricator

Try to allow ', ", & in HTML5 IDs
Closed, ResolvedPublic

Description

escapeId() is currently stripping the ', " and & characters. Is that really necessary? They are apparently allowed in HTML5 as well as in fragments (RFC 3987) and don't cause any known problems other than that they must be escaped in the HTML source. But that applies to all attributes, not just IDs.


Version: unspecified
Severity: enhancement

Details

Reference
bz24919

Event Timeline

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

ayg wrote:

Sanitizer.php comment:

  • To ensure we don't have to bother escaping anything, we also strip ', ",
  • & even if $wgExperimentalIds is true. TODO: Is this the best tactic?
  • We also strip # because it upsets IE, and % because it could be
  • ambiguous if it's part of something that looks like a percent escape
  • (which don't work reliably in fragments cross-browser).

I did this to keep things simple. There are probably places in the code where someone outputs IDs without escaping on the theory that they can't contain special characters, and people will probably continue to assume that in the future even if we audit all existing uses. Developers are not going to expect id's to contain special characters. So I think this should be WONTFIX.

TheDJ claimed this task.
TheDJ subscribed.

This was solved a while back, with improvements to what was then wgexperimentalhtmlids (since has become the default)