Page MenuHomePhabricator

urlencode should take an optional second parameter
Closed, ResolvedPublic


Author: conrad.irwin

There are a few related bugs, but none seem to address this issue directly (that or I have Zarro Bug Foo).

{{urlencode:Hello world}} -> Hello+World

{{urlencode:Hello world|path}} -> Hello%20World

{{urlencode:Hello world|wiki}} -> Hello_World

{{urlencode:Hello world|query}} -> Hello+World

Maybe better to use format=path or for=path for clarity?

Version: unspecified
Severity: enhancement



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:56 PM
bzimport set Reference to bz22474.
bzimport added a subscriber: Unknown Object (MLST).

conrad.irwin wrote:

*** Bug 16868 has been marked as a duplicate of this bug. ***

conrad.irwin wrote:

Implemented as described in r64726

Wiki encoding works fine with FULLPAGENAMEE:

{{urlencode:Hello world|wiki}} <=> {{FULLPAGENAMEE:Hello world}}

Maybe there is no need for a new function.

conrad.irwin wrote:

Not quite, though I appreciate the difference is confusing: FULLPAGENAMEE validates its input for MediaWiki, urlencode does not. Perhaps "WIKI" was a confusing choice of name, but this is really useful for other sites that use an _ for encoding spaces (MediaWiki itself can understand |path}} encoding).

"{{urlencode:<b>|wiki}}" = "%3Cb%3E"
"{{FULLPAGENAMEE:<b>}}" = ""

"{{urlencode:&amp;|WIKI}}" = "%26amp;"
"{{FULLPAGENAMEE:&amp;}}" = "&"

Maybe, given that the difference is just how they encode spaces, it should be |+}} |%}} and |_}} - but that seems a bit leet, and is inflexible if someone wants to add other conventions.

It might also be nice to add a further flag for decoding HTML entities, and/or %-escapes.

  • Bug 24434 has been marked as a duplicate of this bug. ***