Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/250299
Change subject: urldecode() provided input before storing it
......................................................................
urldecode() provided input before storing it
Bug: T117347
Change-Id: Iba67a79d976ce43eae1adf74458f797770526caa
---
M UrlShortener.utils.php
M tests/phpunit/UrlShortenerUtilsTest.php
2 files changed, 8 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UrlShortener
refs/changes/99/250299/1
diff --git a/UrlShortener.utils.php b/UrlShortener.utils.php
index 5bc7b98..e58766d 100755
--- a/UrlShortener.utils.php
+++ b/UrlShortener.utils.php
@@ -78,6 +78,9 @@
// it to a different one when redirecting
$url = self::convertToProtocol( $url, PROTO_HTTP );
+ // Decode it...
+ $url = urldecode( $url );
+
// If the wiki is using an article path (e.g. /wiki/$1) try
// and convert plain index.php?title=$1 URLs to the canonical
form
if ( $wgArticlePath !== false && strpos( $url, '?' ) !== false
) {
diff --git a/tests/phpunit/UrlShortenerUtilsTest.php
b/tests/phpunit/UrlShortenerUtilsTest.php
index 39b8d33..6fd2453 100644
--- a/tests/phpunit/UrlShortenerUtilsTest.php
+++ b/tests/phpunit/UrlShortenerUtilsTest.php
@@ -36,6 +36,8 @@
public static function provideNormalizeUrl() {
return array(
+ // HTTPS -> HTTP
+ array( 'https://example.org', 'http://example.org' ),
// Article normalized
array(
'http://example.com/w/index.php?title=Main_Page',
'http://example.com/wiki/Main_Page' ),
// Already normalized
@@ -48,6 +50,9 @@
array( 'http://example.com/w/index.php.php?foo=bar',
'http://example.com/w/index.php.php?foo=bar' ),
// Additional parameter not normalized
array(
'http://example.com/w/index.php?title=Special:Version&baz=bar',
'http://example.com/w/index.php?title=Special:Version&baz=bar' ),
+ // urldecoded
+ array(
'http://example.org/wiki/Scott_Morrison_%28politician%29',
'http://example.org/wiki/Scott_Morrison_(politician)' ),
+ array(
'http://example.org/wiki/Scott_Morrison_(politician)',
'http://example.org/wiki/Scott_Morrison_(politician)' ),
);
}
--
To view, visit https://gerrit.wikimedia.org/r/250299
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iba67a79d976ce43eae1adf74458f797770526caa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UrlShortener
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits