* (bug 1186) news: in the middle of a word
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 8 Jan 2005 03:03:10 +0000 (03:03 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 8 Jan 2005 03:03:10 +0000 (03:03 +0000)
includes/Parser.php
maintenance/parserTests.txt

index f9571ec..a96db1c 100644 (file)
@@ -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;
                        }
index 0df1d5f..2e94523 100644 (file)
@@ -1786,6 +1786,16 @@ http://example.com[[Image:foobar.jpg]]
 </p>
 !!end
 
+!! test
+Bug 1186 news: in the middle of text
+!! input
+http://en.wikinews.org/wiki/Wikinews:Workplace
+!! result
+<p><a href="http://en.wikinews.org/wiki/Wikinews:Workplace" class='external'>http://en.wikinews.org/wiki/Wikinews:Workplace</a>
+</p>
+!!end
+
+
 TODO:
 more images
 more tables