r402 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r401‎ | r402 | r403 >
Date:00:08, 20 May 2002
Author:axelboldt
Status:old
Tags:
Comment:
More lenient with #REDIRECT syntax: allow one or no brackets.
Modified paths:
  • /trunk/phpwiki/fpw/wikiPage.php (modified) (history)

Diff [purge]

Index: trunk/phpwiki/fpw/wikiPage.php
@@ -124,8 +124,9 @@
125125 }
126126
127127 if ( strtolower ( substr ( $this->contents , 0 , 9 ) ) == "#redirect" and $doRedirect and $action != "edit" and !isset ($oldID) ) { # #REDIRECT
128 - if ( preg_match ( '/^#redirect\s*\[\[\s*([^\]\n]+)\s*\]\]/i' , $this->contents , $regs ) ) {
129 - $target = $regs[1] ;
 128+ # Lenient syntax: two or one or no brackets around the target
 129+ if ( preg_match ( '/^#redirect(\s*\[\[\s*([^\]\n]+)\s*\]\]|\s*\[\s*([^\]\n]+)\s*\]|\s+([^\ \n]*))/i' , $this->contents , $regs ) ) {
 130+ $target = ($regs[2] ? $regs[2] : ($regs[3] ? $regs[3] : $regs[4]));
130131 $link = wikiLink ( $this->getNiceTitle() ) ;
131132 $link = "<a href=\"$link&amp;action=view&amp;redirect=no\">".$this->getNiceTitle()."</a>" ;
132133 $link = str_replace ( "$1" , $link , $wikiRedirectFrom ) ;

Status & tagging log