r5293 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r5292‎ | r5293 | r5294 >
Date:21:02, 18 September 2004
Author:jeluf
Status:old
Tags:
Comment:
BUG#523 Don't remove newlines in front of templates or template variables
Modified paths:
  • /trunk/phase3/includes/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -1443,10 +1443,10 @@
14441444
14451445 if ( $this->mOutputType == OT_HTML ) {
14461446 # Argument substitution
1447 - $text = preg_replace_callback( "/(\\n?){{{([$titleChars]*?)}}}/", 'wfArgSubstitution', $text );
 1447+ $text = preg_replace_callback( "/{{{([$titleChars]*?)}}}/", 'wfArgSubstitution', $text );
14481448 }
14491449 # Template substitution
1450 - $regex = '/(\\n?){{(['.$nonBraceChars.']*)(\\|.*?|)}}/s';
 1450+ $regex = '/{{(['.$nonBraceChars.']*)(\\|.*?|)}}/s';
14511451 $text = preg_replace_callback( $regex, 'wfBraceSubstitution', $text );
14521452
14531453 array_pop( $this->mArgStack );
@@ -1502,15 +1502,13 @@
15031503
15041504 $title = NULL;
15051505
1506 - # $newline is an optional newline character before the braces
15071506 # $part1 is the bit before the first |, and must contain only title characters
15081507 # $args is a list of arguments, starting from index 0, not including $part1
15091508
1510 - $newline = $matches[1];
1511 - $part1 = $matches[2];
1512 - # If the third subpattern matched anything, it will start with |
 1509+ $part1 = $matches[1];
 1510+ # If the second subpattern matched anything, it will start with |
15131511
1514 - $args = $this->getTemplateArgs($matches[3]);
 1512+ $args = $this->getTemplateArgs($matches[2]);
15151513 $argc = count( $args );
15161514
15171515 # {{{}}}
@@ -1719,8 +1717,7 @@
17201718
17211719 # Triple brace replacement -- used for template arguments
17221720 function argSubstitution( $matches ) {
1723 - $newline = $matches[1];
1724 - $arg = trim( $matches[2] );
 1721+ $arg = trim( $matches[1] );
17251722 $text = $matches[0];
17261723 $inputArgs = end( $this->mArgStack );
17271724

Follow-up revisions

RevisionCommit summaryAuthorDate
r5479Fix two parser bugs: bug 41 and bug 529. For the former, I replaced...wmahan05:16, 25 September 2004

Status & tagging log