From f7705e25e5509eaf6c3785e6ddeda17aa463d4ba Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Wed, 22 Feb 2006 09:05:25 +0000 Subject: [PATCH] fix for external links: [url text] (notice two or more spaces) now breaks according to parser test I liked the previous behaviour better, but it doesn't strictly conform to wiki syntax --- includes/Parser.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index 47644b8a89..c4fed1d1b7 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', '/\[(\b(' . wfUrlProtocols() . ')'.EXT_LINK_URL_CLASS.'+) *('.EXT_LINK_TEXT_CLASS.'*?)\]/S' ); +define( 'EXT_LINK_BRACKETED', '/\[(\b(' . wfUrlProtocols() . ')'.EXT_LINK_URL_CLASS.'+)( *)('.EXT_LINK_TEXT_CLASS.'*?)\]/S' ); define( 'EXT_IMAGE_REGEX', '/^('.HTTP_PROTOCOLS.')'. # Protocol '('.EXT_LINK_URL_CLASS.'+)\\/'. # Hostname and path @@ -1085,6 +1085,7 @@ class Parser while ( $imakeExternalLink( $url, $text, false, $linktype ) . $dtrail . $trail; + if ( strlen ( $spaces ) < 2 ) { + # Normal case + $s .= $sk->makeExternalLink( $url, $text, false, $linktype ) . $dtrail . $trail; + } else { + # Fix for [url text] (notice the two blanks) + $s .= '[' . $sk->makeExternalLink( $url, $url, false, "free" ) . $spaces . $text . ']' . $dtrail . $trail; + } # Register link in the output object $this->mOutput->addExternalLink( $url ); -- 2.20.1