From 2c58fbaa29671ec33a879f2bb3724068529c47ff Mon Sep 17 00:00:00 2001 From: "Thiemo Kreuz (WMDE)" Date: Tue, 26 Jun 2018 09:55:21 +0000 Subject: [PATCH] Linker: more consistent whitespace parsing in formatLinksInComment Try to paste and preview this in the wikitext as well as the summary line: [[:a]] [[ :a]] The wikitext will show "a a", but the summary line will show "a :a". This is only a display issue, all 4 links correctly link to the article [[A]]. Change-Id: I08253a6d0b55b9aa3eace519bbdc1a456400bf84 --- includes/Linker.php | 1 + tests/phpunit/includes/LinkerTest.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/includes/Linker.php b/includes/Linker.php index 0ee6c92f77..c0959bf634 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1221,6 +1221,7 @@ class Linker { return preg_replace_callback( '/ \[\[ + \s*+ # ignore leading whitespace, the *+ quantifier disallows backtracking :? # ignore optional leading colon ([^\]|]+) # 1. link target; page names cannot include ] or | (?:\| diff --git a/tests/phpunit/includes/LinkerTest.php b/tests/phpunit/includes/LinkerTest.php index 4c508e3851..b8aecc05a5 100644 --- a/tests/phpunit/includes/LinkerTest.php +++ b/tests/phpunit/includes/LinkerTest.php @@ -294,6 +294,11 @@ class LinkerTest extends MediaWikiLangTestCase { 'foo bar [[Special:BlankPage]]', null, ], + [ + 'Special:BlankPage', + '[[ :Special:BlankPage]]', + null, + ], [ 'Foo\'bar', "[[Foo'bar]]", -- 2.20.1