Page MenuHomePhabricator

PAGENAME returns - instead of - if title starts with a - (hyphen-minus)
Open, Needs TriagePublicBUG REPORT

Description

I know due to the documentation, that the magic word PAGENAME returns a special encoding for some characters (&, ', ") → (&) (') (").

But while developing a lua function i found out, that the Hyphen-Minus character is returned as - if and only if it is the first character of the pages title and has no other characters in front of it like BASEPAGENAME for example. To show the effect i wrote a lua function in Modul:Str function showChars in german wiktionary which adds a blank before every character of the string which is passed as a parameter into it.

This can be seen on the old version of the page '-phorese'
where i used three pagename magic words: PAGENAME, PAGENAMEE and #titleparts:{{PAGENAME}}

https://de.wiktionary.org/w/index.php?title=-phorese&oldid=9969511

On the page https://de.wiktionary.org/wiki/Benutzer:Formatierer/-minus-minus-
this only happens if SUBPAGENAME is used and only for the first of the hyphens.

I know, that this did not happen in Mediawiki version 39.4 because i have a local installation running this version. I don't know in which version this behavior starts and if it is a bug or a feature. If this is not a bug it should be documented.

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

What happens?:

Hyphen-Minus is returned as -

What should have happened instead?:

Hyphen-Minus should have been returned as -

Software version (skip for WMF-hosted wikis like Wikipedia):

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

Event Timeline

That is the result of 3fc635dcb20add63d844dc6f313b41319d6dda30, which is in 1.42.0-wmf.16, not that long ago.

It has the same reason as for the known changes: (&, ', ") → (&) (') (")

As suffixes and interfixes typically start with a hyphen, this bug is visibly breaking a template nl.wiktionary has used for over a decade on hundreds of pages. As far as I can see, this is caused by the magic word PAGESINCATEGORY not recognizing - as a hyphen when used as part of a category name. This change wasn't properly prepared and ought to be reverted for now.

cscott subscribed.

Sounds like the root cause is actually PAGESINCATEGORY. Can you name the template which is breaking on nl.wiktionary so I can test a proper fix?

I already made a fix for the template "huidigbestand" itself. But to enable you to check the behavior of PAGESINCATEGORY I posted a simple test on the talkpage of -en.

If a "root cause" is indeed in PAGESINCATEGORY, then it is also present in #expr (see T361583), and probably many other magic words which all interpret entities literally.

The linked duplicate bug encountered the same issue in yet another context, namely making calculations with a negative year number which consists a Wikipedia PAGENAME.

I don't know who should be doing the escaping and how (whether PAGENAME or all the functions that might be processing its output), but I agree with the above post in that it is unfortunate that ancient inconsistencies are not being resolved out of fear of unforeseen side effects (e.g. the apostrophe, for which the documentation's official suggestion is to use a work-around), while new inconsistencies are being introduced (the initial hyphen/minus), causing eventually the same kind of side effects (i.e. breaking things which used to work for years) without prior warning or documentation.