From 66c2f28ec1ae73cc8b8625b381e91d7e8ac1e42c Mon Sep 17 00:00:00 2001 From: Wil Mahan Date: Mon, 27 Sep 2004 06:13:07 +0000 Subject: [PATCH] Fix "; url://blah blah : definition" definition lists and related cases, noted by brion and JeLuF --- includes/Parser.php | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index 03359201e4..887dccf00e 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -1397,11 +1397,20 @@ class Parser # ; title : definition text # So we check for : in the remainder text to split up the # title and definition, without b0rking links. - # FIXME: This is not foolproof. Something better in Tokenizer might help. - if( preg_match( '/^(.*?):(.*)$/', $t, $match ) ) { - $term = $match[1]; + # Don't count ':' in a URL + $pos = 0; + while (($colon = strpos($t, ':', $pos)) !== false) { + $m1 = substr($t, 0, $colon); + $m2 = substr($t, $colon + 1); + if (!preg_match('/(?:'.URL_PROTOCOLS.')$/', $m1)) { + break; + } + $pos = $colon + 1; + } + if( $colon !== false ) { + $term = $m1; $output .= $term . $this->nextItem( ':' ); - $t = $match[2]; + $t = $m2; } } } elseif( $prefixLength || $lastPrefixLength ) { @@ -1422,10 +1431,19 @@ class Parser if ( ';' == $char ) { # FIXME: This is dupe of code above - if( preg_match( '/^(.*?):(.*)$/', $t, $match ) ) { - $term = $match[1]; + $pos = 0; + while (($colon = strpos($t, ':', $pos)) !== false) { + $m1 = substr($t, 0, $colon); + $m2 = substr($t, $colon + 1); + if (!preg_match('/(?:'.URL_PROTOCOLS.')$/', $m1)) { + break; + } + $pos = $colon + 1; + } + if( $colon !== false ) { + $term = $m1; $output .= $term . $this->nextItem( ':' ); - $t = $match[2]; + $t = $m2; } } ++$commonPrefixLength; -- 2.20.1