From: Thiemo Kreuz (WMDE) Date: Tue, 26 Jun 2018 09:55:21 +0000 (+0000) Subject: Linker: more consistent whitespace parsing in formatLinksInComment X-Git-Tag: 1.34.0-rc.0~4169^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/modifier.php?a=commitdiff_plain;h=2c58fbaa29671ec33a879f2bb3724068529c47ff;p=lhc%2Fweb%2Fwiklou.git 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 --- 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]]",