From: Kevin Israel Date: Tue, 30 Oct 2012 01:49:15 +0000 (-0400) Subject: Add comments to Linker::formatLinksInComment() X-Git-Tag: 1.31.0-rc.0~21466 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;h=a80bc922455134bb992e9f025a34e2152fd33ae6;p=lhc%2Fweb%2Fwiklou.git Add comments to Linker::formatLinksInComment() Per Tim Starling's suggestion, added comments to the regex in Linker::formatLinksInComment(). Change-Id: If85567e5a2e57dd56f5f263f3512e9ed2f9c940c --- diff --git a/includes/Linker.php b/includes/Linker.php index 9b4901573f..408538b7d2 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1376,7 +1376,18 @@ class Linker { self::$commentContextTitle = $title; self::$commentLocal = $local; $html = preg_replace_callback( - '/\[\[:?([^\]|]+)(?:\|((?:]?[^\]|])*+))*\]\]([^[]*)/', + '/ + \[\[ + :? # ignore optional leading colon + ([^\]|]+) # 1. link target; page names cannot include ] or | + (?:\| + # 2. a pipe-separated substring; only the last is captured + # Stop matching at | and ]] without relying on backtracking. + ((?:]?[^\]|])*+) + )* + \]\] + ([^[]*) # 3. link trail (the text up until the next link) + /x', array( 'Linker', 'formatLinksInCommentCallback' ), $comment ); self::$commentContextTitle = null;