From c0d99e5c3e497df89815f4e70f376fac98793011 Mon Sep 17 00:00:00 2001
From: Brion Vibber
Date: Sat, 8 Jan 2005 03:03:10 +0000
Subject: [PATCH] * (bug 1186) news: in the middle of a word
---
includes/Parser.php | 6 +++---
maintenance/parserTests.txt | 10 ++++++++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/includes/Parser.php b/includes/Parser.php
index f9571eca32..a96db1c374 100644
--- a/includes/Parser.php
+++ b/includes/Parser.php
@@ -51,7 +51,7 @@ define( 'EXT_LINK_URL_CLASS', '[^]<>"\\x00-\\x20\\x7F]' );
define( 'EXT_LINK_TEXT_CLASS', '[^\]\\x00-\\x1F\\x7F]' );
define( 'EXT_IMAGE_FNAME_CLASS', '[A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]' );
define( 'EXT_IMAGE_EXTENSIONS', 'gif|png|jpg|jpeg' );
-define( 'EXT_LINK_BRACKETED', '/\[(('.URL_PROTOCOLS.'):'.EXT_LINK_URL_CLASS.'+) *('.EXT_LINK_TEXT_CLASS.'*?)\]/S' );
+define( 'EXT_LINK_BRACKETED', '/\[(\b('.URL_PROTOCOLS.'):'.EXT_LINK_URL_CLASS.'+) *('.EXT_LINK_TEXT_CLASS.'*?)\]/S' );
define( 'EXT_IMAGE_REGEX',
'/^('.HTTP_PROTOCOLS.':)'. # Protocol
'('.EXT_LINK_URL_CLASS.'+)\\/'. # Hostname and path
@@ -1046,7 +1046,7 @@ class Parser
$fname = 'Parser::replaceFreeExternalLinks';
wfProfileIn( $fname );
- $bits = preg_split( '/((?:'.URL_PROTOCOLS.'):)/S', $text, -1, PREG_SPLIT_DELIM_CAPTURE );
+ $bits = preg_split( '/(\b(?:'.URL_PROTOCOLS.'):)/S', $text, -1, PREG_SPLIT_DELIM_CAPTURE );
$s = array_shift( $bits );
$i = 0;
@@ -1220,7 +1220,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('/^((?:'.URL_PROTOCOLS.'):)/', $m[1])) {
+ if (preg_match('/^(\b(?:'.URL_PROTOCOLS.'):)/', $m[1])) {
$s .= $prefix . '[[' . $line ;
continue;
}
diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt
index 0df1d5f876..2e945235f9 100644
--- a/maintenance/parserTests.txt
+++ b/maintenance/parserTests.txt
@@ -1786,6 +1786,16 @@ http://example.com[[Image:foobar.jpg]]
!!end
+!! test
+Bug 1186 news: in the middle of text
+!! input
+http://en.wikinews.org/wiki/Wikinews:Workplace
+!! result
+http://en.wikinews.org/wiki/Wikinews:Workplace
+
+!!end
+
+
TODO:
more images
more tables
--
2.20.1