From 6f49fc4e9de1023cc205a2a350ecc487b03be248 Mon Sep 17 00:00:00 2001 From: River Tarnell Date: Tue, 14 Sep 2004 05:35:34 +0000 Subject: [PATCH] forwardport better fix (thanks brion) --- includes/SpecialMovepage.php | 12 ++++++------ includes/Title.php | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/includes/SpecialMovepage.php b/includes/SpecialMovepage.php index 024390b066..4f0c48d580 100644 --- a/includes/SpecialMovepage.php +++ b/includes/SpecialMovepage.php @@ -122,12 +122,6 @@ class MovePageForm { global $wgUseSquid, $wgRequest; $fname = "MovePageForm::doSubmit"; - # don't allow moving to pages with # in - if ( strchr( $this->newTitle, '#') !== FALSE ) { - $this->showForm( wfMsg( "badtitletext" ) ); - return; - } - # Variables beginning with 'o' for old article 'n' for new article # Attempt to move the article @@ -135,6 +129,12 @@ class MovePageForm { $ot = Title::newFromText( $this->oldTitle ); $nt = Title::newFromText( $this->newTitle ); + # don't allow moving to pages with # in + if ( $nt->getFragment() != '' ) { + $this->showForm( wfMsg( "badtitletext" ) ); + return; + } + $error = $ot->moveTo( $nt ); if ( $error !== true ) { $this->showForm( wfMsg( $error ) ); diff --git a/includes/Title.php b/includes/Title.php index b0897da764..35051844c6 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -770,6 +770,9 @@ class Title { if ( false !== $f ) { $this->mFragment = substr( $f, 1 ); $r = substr( $r, 0, strlen( $r ) - strlen( $f ) ); + # remove whitespace again: prevents "Foo_bar_#" + # becoming "Foo_bar_" + $r = preg_replace( '/_*$/', '', $r ); } # Reject illegal characters. -- 2.20.1