Page MenuHomePhabricator

`Parser::cleanUpTocLine()` does not properly remove all forbidden html elements from the TOC in some edgecases
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Create a page with this content (I realize this is not valid html, I first reproduced this with an image that had a link on it):
__TOC__
==<abbr><abbr></abbr></abbr><abbr><abbr title="abbr title">This is in an abbr</abbr></abbr> Test==
  • Look at the TOC

image.png (223×285 px, 5 KB)

What happens?:

_Some_ but not all abbr elements make it into the TOC

What should have happened instead?:

All elements not in $allowedTags inside the function should be removed.

For reference:

$allowedTags = [ 'span', 'sup', 'sub', 'bdi', 'i', 'b', 's', 'strike', 'q' ];

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

MediaWiki 1.43.3 on my server, also tested on testwiki at https://test.wikipedia.org/wiki/User:FO-nTTaX

Other information (browser name/version, screenshots, etc.):

I don't think this is security relevant as it still would need to survive the parser and the sanitizer, but it's not the correct behaviour in my opinion.

Event Timeline

Change #1190671 had a related patch set uploaded (by Mbergen; author: Mbergen):

[mediawiki/core@master] Fix the premature loop exit in Parser.cleanUpTocLine

https://gerrit.wikimedia.org/r/1190671

Change #1190671 merged by jenkins-bot:

[mediawiki/core@master] Fix the premature loop exit in Parser.cleanUpTocLine

https://gerrit.wikimedia.org/r/1190671

Following this patch being merged, I can't reproduce the issue described in the task description (either locally or at https://test.wikipedia.org/wiki/User:FO-nTTaX). To confirm, @cscott @mbergen is this bug report now resolved? (if so, should the fix be backported?)

Following this patch being merged, I can't reproduce the issue described in the task description (either locally or at https://test.wikipedia.org/wiki/User:FO-nTTaX). To confirm, @cscott @mbergen is this bug report now resolved? (if so, should the fix be backported?)

I consider it resolved, and it would be great if it were backported.

Change #1199841 had a related patch set uploaded (by A smart kitten; author: Mbergen):

[mediawiki/core@REL1_44] Fix the premature loop exit in Parser.cleanUpTocLine

https://gerrit.wikimedia.org/r/1199841

Change #1199842 had a related patch set uploaded (by A smart kitten; author: Mbergen):

[mediawiki/core@REL1_43] Fix the premature loop exit in Parser.cleanUpTocLine

https://gerrit.wikimedia.org/r/1199842

Following this patch being merged, I can't reproduce the issue described in the task description (either locally or at https://test.wikipedia.org/wiki/User:FO-nTTaX). To confirm, @cscott @mbergen is this bug report now resolved? (if so, should the fix be backported?)

I consider it resolved, and it would be great if it were backported.

Thanks! Based on your comment I'm being bold and proposing it for backporting to MW 1.44 & 1.43 (as versions of MediaWiki that are still in support).
I haven't proposed backporting it to MW 1.39, as it looks like the current implementation of Parser::cleanUpTocLine() was introduced in 1.42 (https://gerrit.wikimedia.org/r/1005194), and as - testing locally - it seems like this bug might actually be a regression from that patch.

Change #1199842 merged by jenkins-bot:

[mediawiki/core@REL1_43] Fix the premature loop exit in Parser.cleanUpTocLine

https://gerrit.wikimedia.org/r/1199842

Change #1199841 merged by jenkins-bot:

[mediawiki/core@REL1_44] Fix the premature loop exit in Parser.cleanUpTocLine

https://gerrit.wikimedia.org/r/1199841

A_smart_kitten assigned this task to mbergen.
A_smart_kitten added a subscriber: Zabe.

Thanks @Zabe for merging the backports! Based on previous comments, now calling this resolved :)