Fix URL protocol detection regex for file link= parameter
authorThis, that and the other <at.light@live.com.au>
Sat, 16 Aug 2014 12:09:42 +0000 (22:09 +1000)
committerThis, that and the other <at.light@live.com.au>
Sat, 16 Aug 2014 12:09:42 +0000 (22:09 +1000)
This regex looked something like /^(?i)bitcoin:|ftp://|ftps://|.../, which
meant the anchoring ^ only applied to the first name. This meant that any
link= value that happened to contain a URL protocol anywhere within it
(e.g. wikinews:Foo containing "news:") got incorrectly matched by this
regex.

Bug: 69317
Change-Id: Ide1c4f64137666db99f8e3b6816df01ef5099c8e

includes/parser/Parser.php

index c5c472a..61fffc5 100644 (file)
@@ -5527,7 +5527,7 @@ class Parser {
                                                                $paramName = 'no-link';
                                                                $value = true;
                                                                $validated = true;
-                                                       } elseif ( preg_match( "/^(?i)$prots/", $value ) ) {
+                                                       } elseif ( preg_match( "/^((?i)$prots)/", $value ) ) {
                                                                if ( preg_match( "/^((?i)$prots)$chars+$/u", $value, $m ) ) {
                                                                        $paramName = 'link-url';
                                                                        $this->mOutput->addExternalLink( $value );