r5300 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r5299‎ | r5300 | r5301 >
Date:08:58, 19 September 2004
Author:wmahan
Status:old
Tags:
Comment:
Remove code that is unnecessary now that titles no longer contain
'{' or '}'; fix regex greediness bug in HTML comment removal.
Modified paths:
  • /trunk/phase3/includes/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -1426,9 +1426,7 @@
14271427 $fname = 'Parser::replaceVariables';
14281428 wfProfileIn( $fname );
14291429
1430 - $bail = false;
14311430 $titleChars = Title::legalChars();
1432 - $nonBraceChars = str_replace( array( '{', '}' ), array( '', '' ), $titleChars );
14331431
14341432 # This function is called recursively. To keep track of arguments we need a stack:
14351433 array_push( $this->mArgStack, $args );
@@ -1438,7 +1436,7 @@
14391437
14401438 if ( $this->mOutputType == OT_HTML || $this->mOutputType == OT_MSG ) {
14411439 # Variable substitution
1442 - $text = preg_replace_callback( "/{{([$nonBraceChars]*?)}}/", 'wfVariableSubstitution', $text );
 1440+ $text = preg_replace_callback( "/{{([$titleChars]*?)}}/", 'wfVariableSubstitution', $text );
14431441 }
14441442
14451443 if ( $this->mOutputType == OT_HTML ) {
@@ -1446,7 +1444,7 @@
14471445 $text = preg_replace_callback( "/{{{([$titleChars]*?)}}}/", 'wfArgSubstitution', $text );
14481446 }
14491447 # Template substitution
1450 - $regex = '/{{(['.$nonBraceChars.']*)(\\|.*?|)}}/s';
 1448+ $regex = '/{{(['.$titleChars.']*)(\\|.*?|)}}/s';
14511449 $text = preg_replace_callback( $regex, 'wfBraceSubstitution', $text );
14521450
14531451 array_pop( $this->mArgStack );
@@ -1781,7 +1779,7 @@
17821780 $htmlattrs = $this->getHTMLattrs () ;
17831781
17841782 # Remove HTML comments
1785 - $text = preg_replace( '/(\\n *<!--.*--> *|<!--.*?-->)/sU', '', $text );
 1783+ $text = preg_replace( '/(\\n *<!--.*--> *|<!--.*-->)/sU', '', $text );
17861784
17871785 $bits = explode( '<', $text );
17881786 $text = array_shift( $bits );

Status & tagging log