Page MenuHomePhabricator

{{#titleparts::|1}} returns empty string and possibly other wrong return values
Closed, InvalidPublic

Description

I'm not completely sure if it is a bug but regarding the information given in the documentation I'd assume it is:

As just typing I realized another strange behavior:


Version: unspecified
Severity: minor
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=54044

Details

Reference
bz51750

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 22 2014, 1:54 AM
bzimport added a project: ParserFunctions.
bzimport set Reference to bz51750.
bzimport added a subscriber: Unknown Object (MLST).

":" is not a valid title, single leading ":" is stripped from all titles, and more than one leading ":" is not a valid title again.

"a/:" seems valid and this is probably a bug.

"a/." is invalid title; this is the same as "a" when used in links (you can use "../" and "./" to create subpage-relative links).

Thanks, actually I wasn't really trying to parse titles when I found the bug, so I didn't bother whether those are valid titles or not (and I don't know how the function is supposed to work, e.g. break as it currently does or give a result anyway)

I merely relied on #titleparts documentation given in [1] where it says:

"This function separates a pagetitle into segments based on slashes,
then returns some of those segments as output."

and

"You can use #titleparts as a small "string parser & converter", ..."

so I assumed #titleparts to be implemented only regarding slashes and not checking validity of titles at the same time.

[1] http://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23titleparts

*title*parts convert the given string first to a title and some normalization and validation are done, that includes a leading colon.
You need a 'stringparts' parser function or 'split', that maybe exists already as string function (but not on wmf wikis). You can use lua for this on wmf wikis.

Proprosal INVALID.

The given string to titleparts can also start with a slash:

I found another issue of #titleparts which is actually a little more realistic as the colon examples above.

It seems #titleparts fails as soon as URL encoded characters are included in the URL, see bug 52492.

after fix of bug 54044 titleparts will return :, because on invalid input titleparts returns the input unchanged. This may cause to a dl/dd liste, which is the native behaviour of : on wikitext (the needed newline is always present, see bug 12974).

But this bug is invalid, because titleparts is supposed to parse the input along to the existing title rules, which means that colon is invalid, first letter maybe uppercase and something other, like url encoded parts.

Try to use lua, when plain text split is needed.