Page MenuHomePhabricator

Ampersand (&) in raw-text tags output by extensions should not be encoded during OutputTransform
Closed, ResolvedPublicBUG REPORT

Description

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

  • With an extension outputting <script> tags with & (if-statements) during ParserAfterTidy etc.
  • Fullfils the condition of one of the OutputTransform using RemexCompatFormatter, e.g. with a table of contents
  • Check the transformed page HTML

OR:

  • Create a CSS page in the "Sanitized CSS" content model with
a::before {
	content: "&";
}
  • Use it for <templatestyles> from a wiki page
  • Check the transformed page HTML, or links in the page

What happens?:

Ampersands (&) in the <script>/<styles> tags output by the extension are encoded.

image.png (68×468 px, 9 KB)

What should have happened instead?:

Ampersands (&) in the <script>/<styles> tags output by the extension stay as-is.

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

Not fixed on the master branch.

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

Noticed this because some OutputTransforms are backported to 1.43.4

Event Timeline

Func renamed this task from Ampersand (&) in the <script> tags output by extensions should not be during OutputTransform to Ampersand (&) in the <script> tags output by extensions should not be encoded during OutputTransform.Oct 3 2025, 9:02 PM

Change #1193505 had a related patch set uploaded (by Func; author: Func):

[mediawiki/core@master] RemexCompatFormatter: Don't encode HTML entities in raw-text elements

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

Func renamed this task from Ampersand (&) in the <script> tags output by extensions should not be encoded during OutputTransform to Ampersand (&) in raw-text tags output by extensions should not be encoded during OutputTransform.Oct 3 2025, 10:06 PM
Func updated the task description. (Show Details)

Change #1194991 had a related patch set uploaded (by Arlolra; author: Func):

[mediawiki/core@REL1_44] RemexCompatFormatter: Don't encode HTML entities in raw-text elements

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

Change #1194993 had a related patch set uploaded (by Arlolra; author: Func):

[mediawiki/core@REL1_43] RemexCompatFormatter: Don't encode HTML entities in raw-text elements

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

Change #1194997 had a related patch set uploaded (by Arlolra; author: Func):

[mediawiki/core@REL1_39] RemexCompatFormatter: Don't encode HTML entities in raw-text elements

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

Change #1193505 merged by jenkins-bot:

[mediawiki/core@master] RemexCompatFormatter: Don't encode HTML entities in raw-text elements

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

Change #1194997 merged by jenkins-bot:

[mediawiki/core@REL1_39] RemexCompatFormatter: Don't encode HTML entities in raw-text elements

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

Change #1194993 merged by jenkins-bot:

[mediawiki/core@REL1_43] RemexCompatFormatter: Don't encode HTML entities in raw-text elements

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

Change #1194991 merged by jenkins-bot:

[mediawiki/core@REL1_44] RemexCompatFormatter: Don't encode HTML entities in raw-text elements

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

ABreault-WMF claimed this task.

I encountered this problem when we have a widget (from Widgets extension) that has code of the form

<script>
if ( something && somethingElse ) {
  doStuff()
}
</script>

It replaced the &s by &amp;s on MW 1.43.4 and 1.43.5

I checked, and the change made here fixed my problem.
I assume this change will be part of the MW 1.43.6 release. Is that correct?

I assume this change will be part of the MW 1.43.6 release. Is that correct?

Looks like 1.43.5 was tagged Oct 3 and the backport above was merged Oct 9. Yes, it should be part of the next release