changes list
* (bug 22925) "sp-contributions-blocked-notice-anon" message now displayed when
viewing contributions of a blocked IP address
+* (bug 22474) {{urlencode:}} now takes an optional second paramter for type of
+ escaping.
=== Bug fixes in 1.17 ===
* (bug 17560) Half-broken deletion moved image files to deletion archive
return wfUrlencode( str_replace( ' ', '_', self::ns( $parser, $part1 ) ) );
}
- static function urlencode( $parser, $s = '' ) {
- return urlencode( $s );
+ /**
+ * urlencodes a string according to one of three patterns: (bug 22474)
+ *
+ * By default (for HTTP "query" strings), spaces are encoded as '+'.
+ * Or to encode a value for the HTTP "path", spaces are encoded as '%20'.
+ * For links to "wiki"s, or similar software, spaces are encoded as '_',
+ *
+ * @param $parser.
+ * @param $s String: The text to encode.
+ * @param $arg String (optional): The type of encoding.
+ */
+ static function urlencode( $parser, $s = '', $arg = null ) {
+ static $magicWords = null;
+ if ( is_null( $magicWords ) ) {
+ $magicWords = new MagicWordArray( array( 'url_path', 'url_query', 'url_wiki' ) );
+ }
+ switch( $magicWords->matchStartToEnd( $arg ) ) {
+
+ // Encode as though it's a wiki page, '_' for ' '.
+ case 'url_wiki':
+ return wfUrlencode( str_replace( ' ', '_', $s ) );
+
+ // Encode for an HTTP Path, '%20' for ' '.
+ case 'url_path':
+ return rawurlencode( $s );
+
+ // Encode for HTTP query, '+' for ' '.
+ case 'url_query':
+ default:
+ return urlencode( $s );
+ }
}
static function lcfirst( $parser, $s = '' ) {
'staticredirect' => array( 1, '__STATICREDIRECT__' ),
'protectionlevel' => array( 1, 'PROTECTIONLEVEL' ),
'formatdate' => array( 0, 'formatdate', 'dateformat' ),
+ 'url_path' => array( 0, 'PATH' ),
+ 'url_wiki' => array( 0, 'WIKI' ),
+ 'url_query' => array( 0, 'QUERY' ),
);
/**