mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-23 16:06:53 +00:00
Merge "Fix parsing usernames with +
"
This commit is contained in:
commit
c11460a527
|
@ -1234,7 +1234,7 @@ class CommentParser {
|
|||
) {
|
||||
$parsoidHref = $part['template']['target']['href'];
|
||||
Assert::precondition( substr( $parsoidHref, 0, 2 ) === './', "href has valid format" );
|
||||
$out[] = urldecode( substr( $parsoidHref, 2 ) );
|
||||
$out[] = rawurldecode( substr( $parsoidHref, 2 ) );
|
||||
} else {
|
||||
$out[] = null;
|
||||
}
|
||||
|
|
|
@ -499,7 +499,7 @@ class CommentUtils {
|
|||
) . '/';
|
||||
$matches = null;
|
||||
if ( preg_match( $articlePathRegexp, $path, $matches ) ) {
|
||||
return urldecode( $matches[1] );
|
||||
return rawurldecode( $matches[1] );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ class CommentUtilsTest extends IntegrationTestCase {
|
|||
/**
|
||||
* @covers \MediaWiki\Extension\DiscussionTools\CommentUtils::getTitleFromUrl
|
||||
* @dataProvider provideGetTitleFromUrl_ShortUrl
|
||||
* @dataProvider provideGetTitleFromUrl_Decoding
|
||||
* @dataProvider provideGetTitleFromUrl_ConfusingShortUrl
|
||||
* @dataProvider provideGetTitleFromUrl_NoShortUrl
|
||||
*/
|
||||
|
@ -46,6 +47,23 @@ class CommentUtilsTest extends IntegrationTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
public static function provideGetTitleFromUrl_Decoding() {
|
||||
// Standard short URL configuration like on Wikimedia wikis
|
||||
$config = new HashConfig( [ 'ArticlePath' => '/wiki/$1' ] );
|
||||
|
||||
// In URL paths, non-percent-encoded `+` represents itself
|
||||
yield [ 'A+B', '/wiki/A+B', $config ];
|
||||
yield [ 'A B', '/wiki/A B', $config ];
|
||||
yield [ 'A+B', '/wiki/A%2BB', $config ];
|
||||
yield [ 'A B', '/wiki/A%20B', $config ];
|
||||
|
||||
// In URL query parameters, non-percent-encoded `+` represents ` `
|
||||
yield [ 'A B', '/w/index.php?title=A+B', $config ];
|
||||
yield [ 'A B', '/w/index.php?title=A B', $config ];
|
||||
yield [ 'A+B', '/w/index.php?title=A%2BB', $config ];
|
||||
yield [ 'A B', '/w/index.php?title=A%20B', $config ];
|
||||
}
|
||||
|
||||
public static function provideGetTitleFromUrl_ShortUrl() {
|
||||
// Standard short URL configuration like on Wikimedia wikis
|
||||
$config = new HashConfig( [ 'ArticlePath' => '/wiki/$1' ] );
|
||||
|
|
Loading…
Reference in a new issue