From dac6cd91112991f2a965875480b0af40a17232a3 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 30 Apr 2004 08:19:59 +0000 Subject: [PATCH] Disable the unsafe redirect default on Article::getContent(). A couple tweaks seem to fix editing of redirects problem. Also split up some instances of "?>" in regexp strings. PHP itself doesn't seem to break off the code there, but it's not really recommended (and it confuses the hell out of my editor, breaking syntax highlighting and jumping to functions). --- includes/Article.php | 12 ++++++------ includes/EditPage.php | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index f9d076d4ef..158e1dcf1f 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -62,7 +62,7 @@ class Article { # not told otherwise, and so may cause a change to mTitle. # Return the text of this revision - function getContent( $noredir = false ) + function getContent( $noredir ) { global $wgRequest; @@ -111,7 +111,7 @@ class Article { # split it up by section $secs = preg_split( - "/(^=+.*?=+|^.*?<\/h[1-6].*?>)/mi", + "/(^=+.*?=+|^.*?<\/h[1-6].*?" . ">)/mi", $striptext, -1, PREG_SPLIT_DELIM_CAPTURE); @@ -483,7 +483,7 @@ class Article { } } - $text = $this->getContent(); # May change mTitle + $text = $this->getContent( false ); # May change mTitle by following a redirect $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); # We're looking at an old revision @@ -586,7 +586,7 @@ class Article { /* Side effects: loads last edit */ function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = ""){ $this->loadLastEdit(); - $oldtext = $this->getContent(); + $oldtext = $this->getContent( true ); if ($section != "") { if($section=="new") { if($summary) $subject="== {$summary} ==\n\n"; @@ -602,7 +602,7 @@ class Article { # now that we can be sure that no pseudo-sections are in the source, # split it up - $secs=preg_split("/(^=+.*?=+|^.*?<\/h[1-6].*?>)/mi", + $secs=preg_split("/(^=+.*?=+|^.*?<\/h[1-6].*?" . ">)/mi", $oldtext,-1,PREG_SPLIT_DELIM_CAPTURE); $secs[$section*2]=$text."\n\n"; // replace with edited if($section) { $secs[$section*2-1]=""; } // erase old headline @@ -1197,7 +1197,7 @@ class Article { return; } if ( wfReadOnly() ) { - $wgOut->readOnlyPage( $this->getContent() ); + $wgOut->readOnlyPage( $this->getContent( true ) ); return; } diff --git a/includes/EditPage.php b/includes/EditPage.php index 52f409371b..f41ce5c78a 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -33,7 +33,7 @@ class EditPage { $this->importFormData( $wgRequest ); if ( ! $this->mTitle->userCanEdit() ) { - $wgOut->readOnlyPage( $this->mArticle->getContent(), true ); + $wgOut->readOnlyPage( $this->mArticle->getContent( true ), true ); return; } if ( $wgUser->isBlocked() ) { @@ -48,7 +48,7 @@ class EditPage { if( $this->save || $this->preview ) { $this->editForm( "preview" ); } else { - $wgOut->readOnlyPage( $this->mArticle->getContent() ); + $wgOut->readOnlyPage( $this->mArticle->getContent( true ) ); } return; } @@ -194,7 +194,7 @@ class EditPage { if ( "initial" == $formtype ) { $this->edittime = $this->mArticle->getTimestamp(); - $this->textbox1 = $this->mArticle->getContent(true); + $this->textbox1 = $this->mArticle->getContent( true ); $this->summary = ""; $this->proxyCheck(); } @@ -209,7 +209,7 @@ class EditPage { $wgOut->addHTML( wfMsg( "explainconflict" ) ); $this->textbox2 = $this->textbox1; - $this->textbox1 = $this->mArticle->getContent(true); + $this->textbox1 = $this->mArticle->getContent( true ); $this->edittime = $this->mArticle->getTimestamp(); } else { $s = wfMsg( "editing", $this->mTitle->getPrefixedText() ); -- 2.20.1