forwardport better fix (thanks brion)
authorRiver Tarnell <kateturner@users.mediawiki.org>
Tue, 14 Sep 2004 05:35:34 +0000 (05:35 +0000)
committerRiver Tarnell <kateturner@users.mediawiki.org>
Tue, 14 Sep 2004 05:35:34 +0000 (05:35 +0000)
includes/SpecialMovepage.php
includes/Title.php

index 024390b..4f0c48d 100644 (file)
@@ -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 ) );
index b0897da..3505184 100644 (file)
@@ -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.