Last modified: 2013-12-07 13:13:16 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T53750, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 51750 - {{#titleparts::|1}} returns empty string and possibly other wrong return values
{{#titleparts::|1}} returns empty string and possibly other wrong return values
Status: RESOLVED INVALID
Product: MediaWiki extensions
Classification: Unclassified
ParserFunctions (Other open bugs)
unspecified
All All
: Lowest minor with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-20 14:02 UTC by Eduard Braun
Modified: 2013-12-07 13:13 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Eduard Braun 2013-07-20 14:02:50 UTC
I'm not completely sure if it is a bug but regarding the information given in the documentation I'd assume it is:

{{#titleparts::|1}} returns an empty string "" but should probably return ":" as

{{#titleparts:.|1}} returns "." and 

{{#titleparts:a|1}} returns "A"



As just typing I realized another strange behavior:

{{#titleparts:a/b|1|2}} returns b as supposed to, while

{{#titleparts:a/:|1|2}} returns again an empty string "" and

{{#titleparts:a/.|1|2}} even returns the completely wrong "a/."
Comment 1 Bartosz Dziewoński 2013-07-20 14:07:42 UTC
":" 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).
Comment 2 Eduard Braun 2013-07-20 14:19:48 UTC
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
Comment 3 db [inactive,noenotif] 2013-08-01 08:32:32 UTC
*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:

{{#titleparts:/a|1|2}} returns a
Comment 4 Eduard Braun 2013-08-03 01:28:46 UTC
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.
Comment 5 db [inactive,noenotif] 2013-12-07 13:13:16 UTC
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.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links