(Bug 26410) In an internal link, a plus sign is treated as a space if the link

has a % sign in it, but interperted as a + if no % sign is present.

This changes how the parser interperts links slightly. However:
*I can't imagine anyone is relying on this behaviour
*Things should be consistent. a + sign shouldn't magically change meaning
if there is a % sign somewhere else in the link.
*Pages are allowed to contain % signs in their title, and + signs,
you should be able to link to such pages just by typing there name without
resorting to %2B.
*If you have a page named foo%+ having [[{{PAGENAME}}]] link to a different
page seems inherently wrong.
*The previous behaviour seemed accidental.
This commit is contained in:
Brian Wolff 2010-12-24 09:53:08 +00:00
parent 5929ae5798
commit ff5394caed
4 changed files with 7 additions and 7 deletions

View file

@ -40,6 +40,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
* (bug 18372) File types blacklisted by $wgFileBlacklist will no longer be shown as
"Permitted file types" on the upload form
* (bug 26379) importImages.php gives more descriptive error message on failure.
* (Bug 26410) + signs are no longer treated as spaces in internal links if
link has a % sign in it.
=== API changes in 1.18 ===
* (bug 26339) Throw warning when truncating an overlarge API result

View file

@ -1102,7 +1102,7 @@ class Linker {
# fix up urlencoded title texts (copied from Parser::replaceInternalLinks)
if ( strpos( $match[1], '%' ) !== false ) {
$match[1] = str_replace( array( '<', '>' ), array( '&lt;', '&gt;' ), urldecode( $match[1] ) );
$match[1] = str_replace( array( '<', '>' ), array( '&lt;', '&gt;' ), rawurldecode( $match[1] ) );
}
# Handle link renaming [[foo|text]] will show link as "text"

View file

@ -411,9 +411,7 @@ class Title {
// and URL-decode links
if ( strpos( $m[1], '%' ) !== false ) {
// Match behavior of inline link parsing here;
// don't interpret + as " " most of the time!
// It might be safe to just use rawurldecode instead, though.
$m[1] = urldecode( ltrim( $m[1], ':' ) );
$m[1] = rawurldecode( ltrim( $m[1], ':' ) );
}
$title = Title::newFromText( $m[1] );
// If the title is a redirect to bad special pages or is invalid, return null

View file

@ -1726,14 +1726,14 @@ class Parser {
# fix up urlencoded title texts
if ( strpos( $m[1], '%' ) !== false ) {
# Should anchors '#' also be rejected?
$m[1] = str_replace( array('<', '>'), array('&lt;', '&gt;'), urldecode( $m[1] ) );
$m[1] = str_replace( array('<', '>'), array('&lt;', '&gt;'), rawurldecode( $m[1] ) );
}
$trail = $m[3];
} elseif ( preg_match( $e1_img, $line, $m ) ) { # Invalid, but might be an image with a link in its caption
$might_be_img = true;
$text = $m[2];
if ( strpos( $m[1], '%' ) !== false ) {
$m[1] = urldecode( $m[1] );
$m[1] = rawurldecode( $m[1] );
}
$trail = "";
} else { # Invalid form; output directly
@ -4507,7 +4507,7 @@ class Parser {
}
if ( strpos( $matches[0], '%' ) !== false ) {
$matches[1] = urldecode( $matches[1] );
$matches[1] = rawurldecode( $matches[1] );
}
$tp = Title::newFromText( $matches[1] );
$nt =& $tp;