(bug 30236) Links like [[//example.com Link text]] were parsed as an internal link...
authorRoan Kattouw <catrope@users.mediawiki.org>
Fri, 12 Aug 2011 13:32:06 +0000 (13:32 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Fri, 12 Aug 2011 13:32:06 +0000 (13:32 +0000)
includes/parser/Parser.php
tests/parser/parserTests.txt

index 9e85556..6389170 100644 (file)
@@ -1896,7 +1896,7 @@ class Parser {
                        # Don't allow internal links to pages containing
                        # PROTO: where PROTO is a valid URL protocol; these
                        # should be external links.
-                       if ( preg_match( '/^\b(?:' . wfUrlProtocols() . ')/', $m[1] ) ) {
+                       if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $m[1] ) ) {
                                $s .= $prefix . '[[' . $line ;
                                wfProfileOut( __METHOD__."-misc" );
                                continue;
index 2c465d0..6903877 100644 (file)
@@ -2197,6 +2197,34 @@ Plain link to URL
 </p>
 !! end
 
+!! test
+Plain link to URL with link text
+!! input
+[[http://www.example.com Link text]]
+!! result
+<p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
+</p>
+!! end
+
+!! test
+Plain link to protocol-relative URL
+!! input
+[[//www.example.com]]
+!! result
+<p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
+</p>
+!! end
+
+!! test
+Plain link to protocol-relative URL with link text
+!! input
+[[//www.example.com Link text]]
+!! result
+<p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
+</p>
+!! end
+
+
 # I'm fairly sure the expected result here is wrong.
 # We want these to be URL links, not pseudo-pages with URLs for titles....
 # However the current output is also pretty screwy.