Page MenuHomePhabricator

Attribute displaytitle without {{DISPLAYTITLE}} contains incomplete HTML encoding
Closed, ResolvedPublicBUG REPORT

Description

https://www.mediawiki.org/w/api.php?action=parse&format=json&formatversion=2&title=A%26b&prop=displaytitle&text={{DISPLAYTITLE:a%26b}}foo answers with:

{
  "parse": {
    "title": "A&b",
    "pageid": 0,
    "displaytitle": "a&b"
  }
}

https://www.mediawiki.org/w/api.php?action=parse&format=json&formatversion=2&title=A%26b&prop=displaytitle&text=foo answers with:

{
  "parse": {
    "title": "A&b",
    "pageid": 0,
    "displaytitle": "A&b"
  }
}

Expected result:

{
  "parse": {
    "title": "A&b",
    "pageid": 0,
    "displaytitle": "A&b"
  }
}

with correct HTML encoding A&b instead of A&b.

Details

Related Changes in Gerrit:

Event Timeline

And also https://www.mediawiki.org/w/api.php?action=query&formatversion=2&prop=info&inprop=displaytitle&titles=A%26B with the current response

{
    "batchcomplete": true,
    "query": {
        "pages": [
            {
                "ns": 0,
                "title": "A&B",
                "missing": true,
                "contentmodel": "wikitext",
                "pagelanguage": "en",
                "pagelanguagehtmlcode": "en",
                "pagelanguagedir": "ltr",
                "displaytitle": "A&B"
            }
        ]
    }
}

The two examples from https://html.spec.whatwg.org/#syntax-errors

<a href="?bill&ted">Bill and Ted</a> <!-- &ted is ok, since it's not a named character reference -->

<a href="?art&amp;copy">Art and Copy</a> <!-- the & has to be escaped, since &copy is a named character reference -->

shows the problem with HTML entities. This is visible on https://www.mediawiki.org/wiki/art&copy?action=info:

Information for "Art&copy"

Basic information
Display titleArt©
Default sort keyArt&copy

because it contains:

<tr id="mw-pageinfo-display-title"><td style="vertical-align: top;">Display title</td><td>Art&copy</td></tr>
<tr id="mw-pageinfo-default-sort"><td style="vertical-align: top;">Default sort key</td><td>Art&amp;copy</td></tr>

Change 725873 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/core@master] [WIP] Encode & by &amp; in displaytitle fallback

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

Change 725873 merged by Fomafix:

[mediawiki/core@master] Encode & to &amp; in displaytitle fallback

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

Hi there, it seems like this has make a big problem,

Have a look at

https://zh.wikipedia.org/w/index.php?title=IPhone_XS&oldid=68055910

https://zh.wikipedia.org/w/index.php?oldid=68234793

Seems like html tag can't use after this marge.

@Jonathan5566 Can you create a new but report?

zhwiki is strange. On a preview I can set arbitrary title with a {{DISPLAYTITLE:...}}. This should be normally not possible.

I found the reason for the different behavior on zhwiki. On zhwiki is:

$wgRestrictDisplayTitle = false

Source: https://gerrit.wikimedia.org/g/operations/mediawiki-config/+/acc9b3c6437175981b041a10f392a3e7d4590509/wmf-config/InitialiseSettings.php#13973

A

{{DISPLAYTITLE:iPhone Xs}}

and a

{{DISPLAYTITLE:iPhone X<span style="font-variant: small-caps; text-transform: lowercase;">S</span>}}

still works with $wgRestrictDisplayTitle = false.

@Jonathan5566 Can you create a new but report?

@Fomafix I have created a bug report T294612, we can continue our conversation there. You can close this ticket now.

https://www.mediawiki.org/w/api.php?action=parse&format=json&formatversion=2&title=A%26b&prop=displaytitle&text=foo answers

{
  "parse": {
    "title": "A&b",
    "pageid": 0,
    "displaytitle": "A&amp;b"
  }
}

https://www.mediawiki.org/wiki/A&B?action=info contains

<td>A&amp;B</td>

https://www.mediawiki.org/w/api.php?action=query&formatversion=2&prop=info&inprop=displaytitle&titles=A%26B answers

{
    "batchcomplete": true,
    "query": {
        "pages": [
            {
                "ns": 0,
                "title": "A&B",
                "missing": true,
                "contentmodel": "wikitext",
                "pagelanguage": "en",
                "pagelanguagehtmlcode": "en",
                "pagelanguagedir": "ltr",
                "displaytitle": "A&amp;B"
            }
        ]
    }
}