Page MenuHomePhabricator

HTML tags in Entity diff title
Closed, ResolvedPublicBUG REPORT

Description

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

What happens?:

There are HTML tags visible in the title: <span class="wikibase-title-id">(Q56668748)</span>

image.png (174×819 px, 30 KB)

What should have happened instead?:

There should be no HTML-tags in the title

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

Event Timeline

Can now confirm that it is indeed the change mentioned in the description that introduced the issue. Changing the code modified in \Wikibase\Repo\Actions\ViewEntityAction::setDiffPageTitle to use \Message::rawParams instead of \Message::plaintextParams does fix the issues without introducing a XSS vulnerability:

image.png (304×738 px, 46 KB)

But the styling looks wrong. Has it always been this way?

But the styling looks wrong. Has it always been this way?

I think so; this random Wikibase Cloud wiki diff looks the same.

Though it is not as simple as just changing plainTextParams -> rawParams, because that would still parse some HTML tags like <b> (see screenshot). But it should not be terribly harder, maybe we just need to do some extra escaping ourselves.

image.png (588×633 px, 80 KB)

IIRC the recommended approach is that we do whatever escaping we need and then return that as a RawMessage.

I couldn't reproduce this at first, it turns out that Wikibase generates different page titles for diffs depending on the 'diffonly' option:

So… maybe the styling (which looked wrong to @Michael above :) ) isn't actually intended, just happening by accident when the page content is displayed below the diff?

Though it is not as simple as just changing plainTextParams -> rawParams, because that would still parse some HTML tags like <b> (see screenshot). But it should not be terribly harder, maybe we just need to do some extra escaping ourselves.

->plaintextParams( $titleText . $id ) should probably become ->rawParams( htmlspecialchars( $titleText ) . $id )

So… maybe the styling (which looked wrong to @Michael above :) ) isn't actually intended, just happening by accident when the page content is displayed below the diff?

Given that it’s set in a method named setDiffPageTitle (see T347578#9206634), it’s obviously quite intended that it appears on diffs with diffonly=0. The accidental thing is that it doesn’t appear on diffs with diffonly=1 – if I understand the code correctly, the data it uses is set in an OutputPageParserOutput hook handler, which seems not to run with diffonly=1 (which sounds right on core’s side, why would the hook run if there’s no parsed content on the page?).

Change 962646 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] Fix diff title escaping

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

Change 962646 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Fix diff title escaping

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

Change 962214 had a related patch set uploaded (by Bartosz Dziewoński; author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@wmf/1.41.0-wmf.28] Fix diff title escaping

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

Change 962214 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@wmf/1.41.0-wmf.28] Fix diff title escaping

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

Mentioned in SAL (#wikimedia-operations) [2023-10-02T21:07:45Z] <kindrobot@deploy2002> Started scap: Backport for [[gerrit:962212|Ignore <!--comment--> only site notices (T347645)]], [[gerrit:962213|HookUtils: Fix checking page props (T347878)]], [[gerrit:962214|Fix diff title escaping (T347578)]], [[gerrit:962215|Diff: Add missing .mw-diff-inline-moved selector]]

Mentioned in SAL (#wikimedia-operations) [2023-10-02T21:08:59Z] <kindrobot@deploy2002> kindrobot and matmarex: Backport for [[gerrit:962212|Ignore <!--comment--> only site notices (T347645)]], [[gerrit:962213|HookUtils: Fix checking page props (T347878)]], [[gerrit:962214|Fix diff title escaping (T347578)]], [[gerrit:962215|Diff: Add missing .mw-diff-inline-moved selector]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2023-10-02T21:17:51Z] <kindrobot@deploy2002> Finished scap: Backport for [[gerrit:962212|Ignore <!--comment--> only site notices (T347645)]], [[gerrit:962213|HookUtils: Fix checking page props (T347878)]], [[gerrit:962214|Fix diff title escaping (T347578)]], [[gerrit:962215|Diff: Add missing .mw-diff-inline-moved selector]] (duration: 10m 06s)

matmarex claimed this task.

Fixed and deployed

Thanks @Lucas_Werkmeister_WMDE and @matmarex for fixing it! Is it worth it creating a task to eliminate the difference between diffonly=1 and diffonly=0?