Page MenuHomePhabricator

Sanitizer damages block content (especially <ol>) in output when wrapped in <span>
Closed, ResolvedPublic

Description

Author: dannychia

Description:
For some reason, the numbered list is showing the numbers 1, 3, 4, and 5, skipping the number 2.


Version: unspecified
Severity: major
URL: http://en.wikipedia.org/w/index.php?title=User_talk:ClueBot&oldid=150881319

Details

Reference
bz10901

Event Timeline

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

There's unclosed <span> tag right before the list. It's actually closed at the end of one before last paragraph. Rewrite "span" to "div" in both.


Although solution is simple, this is still a big bug.

I've done some observation and here are some clues for whoever will be fixing it:

  • if the <span> is followed by <ol>, the output has unexplainable <li style="list-style: none"></li> as the second item of the list (= it adds one dummy item)
  • each blocklevel tag within the wrong wrapping <span> which doesn't contain any other blocklevel tag is padded with the copy of the wrong wrapping tag, or rather each inline stuff is wrapped in the copy.

<span class="foo">

  1. 1
  2. 2
  3. 3

<div class="bar">
lorem
#1
#2
#3
abc<div class="quo">ipsum</div>def
</div>
</span>

produces

<ol>
<li><span class="foo">1</span></li>
<li style="list-style: none"></li>
<li><span class="foo">2</span></li>
<li><span class="foo">3</span></li>
</ol>
<div class="bar">
<p><span class="foo">lorem</span></p>
<ol>
<li><span class="foo">1</span></li>
<li style="list-style: none"></li>
<li><span class="foo">2</span></li>
<li><span class="foo">3</span></li>
</ol>
<span class="foo">abc</span>
<div class="quo"><span class="foo">ipsum</span></div>
<span class="foo">def</span></div>


Although this might have been some kind of help for bad-coding users to display things "properly" (rather visually properly), it is real pain. There should be absolutely no stuff added in output code this way, because it totally changes the DOM tree of page (so some scripts may not work) besides it raises up the output size of the page (imagine somebody will wrap entire page in this span).

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