Parser: Trim leading whitespace from links before checking for leading :
authorThis, that and the other <at.light@live.com.au>
Tue, 27 Dec 2016 09:51:50 +0000 (20:51 +1100)
committerUmherirrender <umherirrender_de.wp@web.de>
Sat, 21 Jan 2017 23:55:02 +0000 (23:55 +0000)
The leading spaces on the link only cause us problems, such as for the
$noforce check 20 lines later.

Bug: T129218
Change-Id: I93a8da1f73b38fa3da362f8f27479b3039ed3f13

includes/parser/Parser.php
tests/parser/parserTests.txt

index 702a479..3ec0596 100644 (file)
@@ -2201,7 +2201,7 @@ class Parser {
                                continue;
                        }
 
-                       $origLink = $m[1];
+                       $origLink = ltrim( $m[1], ' ' );
 
                        # Don't allow internal links to pages containing
                        # PROTO: where PROTO is a valid URL protocol; these
index 3853a12..ed09203 100644 (file)
@@ -8590,6 +8590,22 @@ Blah blah blah
 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
 !! end
 
+!! test
+Escaping of interlanguage links
+!! wikitext
+Blah blah blah
+[[:es:Spanish]]
+[[ : zh : Chinese ]]
+!! html/php
+<p>Blah blah blah
+<a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
+<a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
+<a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
+!! end
+
 ## parsoid html2wt will normalize the space to _
 !! test
 Space and question mark encoding in interlanguage links (T95473)