From: Kevin Israel Date: Thu, 25 Oct 2012 13:54:52 +0000 (-0400) Subject: Optimized regex in Linker.php X-Git-Tag: 1.31.0-rc.0~21467 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=3a751a39b17f8f2ccc1c4ae2ed8353ef5f77e5ea;p=lhc%2Fweb%2Fwiklou.git Optimized regex in Linker.php Optimized the regex in Linker::formatLinksInComment(). Change-Id: Idea5554bcb8d7e78ddf972ce4c9827fa738ff837 --- diff --git a/includes/Linker.php b/includes/Linker.php index 12edcc85c2..9b4901573f 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1376,7 +1376,7 @@ class Linker { self::$commentContextTitle = $title; self::$commentLocal = $local; $html = preg_replace_callback( - '/\[\[:?(.*?)(\|(.*?))*\]\]([^[]*)/', + '/\[\[:?([^\]|]+)(?:\|((?:]?[^\]|])*+))*\]\]([^[]*)/', array( 'Linker', 'formatLinksInCommentCallback' ), $comment ); self::$commentContextTitle = null; @@ -1402,8 +1402,8 @@ class Linker { } # Handle link renaming [[foo|text]] will show link as "text" - if ( $match[3] != "" ) { - $text = $match[3]; + if ( $match[2] != "" ) { + $text = $match[2]; } else { $text = $match[1]; } @@ -1418,7 +1418,7 @@ class Linker { } } else { # Other kind of link - if ( preg_match( $wgContLang->linkTrail(), $match[4], $submatch ) ) { + if ( preg_match( $wgContLang->linkTrail(), $match[3], $submatch ) ) { $trail = $submatch[1]; } else { $trail = "";