From 7e13964a0285c0e5e8e313a6dd1cd723de1752d8 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Fri, 12 Aug 2011 13:32:06 +0000 Subject: [PATCH] (bug 30236) Links like [[//example.com Link text]] were parsed as an internal link rather than an external link surrounded by brackets, like [[http://example.com Link text]]. Was caused by another pointless \b directly preceding wfUrlProtocols() in a regex. Also add a parser test for the [[http://example.com Link text]] case (the existing test only covered [[http://example.com]]) and add protocol-relative counterparts for both tests. --- includes/parser/Parser.php | 2 +- tests/parser/parserTests.txt | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 9e85556915..63891702ca 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -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; diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 2c465d0c32..6903877eea 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -2197,6 +2197,34 @@ Plain link to URL

!! end +!! test +Plain link to URL with link text +!! input +[[http://www.example.com Link text]] +!! result +

[Link text] +

+!! end + +!! test +Plain link to protocol-relative URL +!! input +[[//www.example.com]] +!! result +

[[1]] +

+!! end + +!! test +Plain link to protocol-relative URL with link text +!! input +[[//www.example.com Link text]] +!! result +

[Link text] +

+!! 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. -- 2.20.1