Page MenuHomePhabricator

Wikitext badly escaped on wishes page
Closed, ResolvedPublic8 Estimated Story PointsBUG REPORT

Description

https://meta.wikimedia.org/wiki/Community_Wishlist/W309 shows up on https://meta.wikimedia.org/wiki/Community_Wishlist/Wishes as "Make subreferencing work with inline refs and {{reflist}} "

QA notes

What we're looking for here are two things (combines T407961 which I didn't send to QA because it's been fixed in prod for a while):

  • XSS vulnerabilities in wish titles i.e. <script>alert('foo');</script> particularly when viewing a wish with realtime preview and in our own wish-index table
  • What you type in the tile is (generally) what should be seen. I.e. <b>{{reflist}}</b> [[wish]] search test <gallery></gallery> should appear the same when viewing the wish by any means, as opposed to the <b> tags and the [[link]] being rendered, etc.
    • An expected exception are <span> tags with either or both a lang or dir attribute. These are rendered and preserved because we can't differ them from <span> tags added by Extension:Translate.

Further details (may not need to be QA'd directly):

  • The saved wikitext should be escaped when necessary. The previous example would get saved as <b>&#123;&#123;reflist&#125;&#125;</b> &#91;&#91;wish&#93;&#93; search test &lt;gallery&gt;&lt;/gallery&gt;
    • Just mentioning this for completeness sake. There's no need to manually verify the HTML escaping is correct, as verifying it loads as expected in Special:WishlistIntake should cover it.
  • Fuzzy translations should be rendered
    • Create or use an existing wish that's (a) marked for translation and (b) has the title translated in at least one other language
    • Edit the wish and change the tile
    • Re-mark for translation
    • Browse to the translation subpage of the other language, and the title should be highlighted as the the translation is outdated

Derived Requirement

Ensure that wish titles on the Community Wishlist display user-entered wikitext literally across all viewing contexts (including realtime preview, wish pages, and the wish-index table), without rendering HTML or wikitext, except for <span> tags containing lang or dir attributes, which should be preserved. Prevent execution of any scripted or injected HTML. When a translated wish title becomes outdated due to edits, its translation subpage should correctly indicate that it is fuzzy/outdated.

Test Steps

Test Case 1: Validate Literal Wikitext Display, XSS Protection, and Outdated Translation Highlighting

  1. Navigate to Special:'WishlistIntake' and create a new wish (or edit an existing one).
  2. In the title field, enter wikitext such as <b>{{reflist}}</b> [[wish]] search test <gallery></gallery>.
  3. Save the wish and view it on: • its wish page • the Community_Wishlist/Wishes index • realtime preview
  4. Insert an XSS test string in the title such as <script>alert('foo');</script> and save.
  5. Create or use an existing translated wish that has at least one other language translation.
  6. Edit the wish title, save, and re-mark it for translation.
  7. Navigate to the translated language subpage.
  8. ✅❓❌⬜ AC1: Confirm that the title displays *literally* without rendering <b>, [[link]], <gallery>, or other wikitext/HTML in any viewing location.
  9. ✅❓❌⬜ AC2: Confirm that <span> tags containing lang and/or dir attributes are preserved and rendered.
  10. ✅❓❌⬜ AC3: Confirm that no script or injected HTML (e.g., <script>alert('foo');</script>) executes anywhere, including realtime preview and the wish-index table.

QA Results - Meta Beta

ACStatusDetails
1T407000#11426063
2T407000#11426063
3T407000#11426063

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

@Vishnu_mishra Are you planning on working on this? You most certainly are welcome to, but I wanted to note the overlap with T406998. I believe we need to render wish titles as HTML to fix T407004: MinT translation does not translate the entity title nor status. We will need to do some escaping to prevent i.e. a wish called <script>alert('I steal yo cookies!')</script> but HTML entities and the markup we introduce around the title will get rendered.

So I think this task, T406998 and T407004 all have the same solution.

Grr, sorry! Not technically a duplicate, though the fix will be similar.

MusikAnimal added a subscriber: Vishnu_mishra.

I am going to unassign @Vishnu_mishra however, as we have not heard back from them.

MusikAnimal changed the subtype of this task from "Task" to "Bug Report".

Change #1200744 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/CommunityRequests@master] Ensure titles are HTML-safe for display, and sanitized in storage

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

MusikAnimal changed the task status from Open to In Progress.Nov 3 2025, 8:13 PM
MusikAnimal claimed this task.

Change #1200744 merged by jenkins-bot:

[mediawiki/extensions/CommunityRequests@master] Ensure titles are sanitized for display and storage

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

Change #1203758 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/CommunityRequests@master] Escape wikitext syntax in wikitext storage, but keep it everywhere else

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

Change #1206055 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/core@master] parser: Add an option to Sanitizer::removeSomeTags() to allow comments

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

Change #1206055 merged by jenkins-bot:

[mediawiki/core@master] parser: Add an option to Sanitizer::removeSomeTags() to allow comments

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

MusikAnimal set the point value for this task to 8.Nov 21 2025, 7:51 AM

Change #1203758 merged by jenkins-bot:

[mediawiki/extensions/CommunityRequests@master] Escape wikitext syntax in wikitext storage, but keep it everywhere else

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

HMonroy changed the task status from In Progress to Open.Nov 25 2025, 1:25 AM

@MusikAnimal Confirmed that wish titles on the Community Wishlist display user-entered wikitext literally across all viewing contexts (including wish pages, and the wish-index table), without rendering HTML or wikitext, except for <span> tags containing lang or dir attributes, which should be preserved, per videos below. I will mark this as Resolved. Thanks for all your work!

Test Result - Meta Beta

Status: ✅ PASS
Environment: Meta Beta
OS: macOS Tahoe 26.1
Browser: Chrome 142
Device: MBA
Emulated Device: NA

Test Artifact(s):

Test Steps

Test Case 1: Validate Literal Wikitext Display, XSS Protection, and Outdated Translation Highlighting

  1. Navigate to Special:'WishlistIntake' and create a new wish (or edit an existing one).
  2. In the title field, enter wikitext such as <b>{{reflist}}</b> [[wish]] search test <gallery></gallery>.
  3. Save the wish and view it on: • its wish page • the Community_Wishlist/Wishes index • realtime preview
  4. Insert an XSS test string in the title such as <script>alert('foo');</script> and save.
  5. Create or use an existing translated wish that has at least one other language translation.
  6. Edit the wish title, save, and re-mark it for translation.
  7. Navigate to the translated language subpage.
  8. AC1: Confirm that the title displays *literally* without rendering <b>, [[link]], <gallery>, or other wikitext/HTML in any viewing location.
DesktopMobile
  1. AC2: Confirm that <span> tags containing lang and/or dir attributes are preserved and rendered.

See AC1

  1. AC3: Confirm that no script or injected HTML (e.g., <script>alert('Sharks');</script>) executes anywhere, including the wish-index table.

GMikesell-WMF updated the task description. (Show Details)
GMikesell-WMF updated Other Assignee, removed: GMikesell-WMF.