r87483 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87482‎ | r87483 | r87484 >
Date:05:31, 5 May 2011
Author:tstarling
Status:ok
Tags:
Comment:
* Fix for bug 28534: IE 6 content type detection again
* Fix for bug 28639: user object instance cache pollution
Modified paths:
  • /branches/REL1_17/phase3/images/.htaccess (modified) (history)
  • /branches/REL1_17/phase3/img_auth.php (modified) (history)
  • /branches/REL1_17/phase3/includes/User.php (modified) (history)
  • /branches/REL1_17/phase3/includes/WebRequest.php (modified) (history)

Diff [purge]

Index: branches/REL1_17/phase3/images/.htaccess
@@ -1,6 +1,6 @@
22 # Protect against bug 28235
33 <IfModule rewrite_module>
44 RewriteEngine On
5 - RewriteCond %{QUERY_STRING} \.[a-z0-9]{1,4}(#|\?|$) [nocase]
 5+ RewriteCond %{QUERY_STRING} \.[^\\/:*?\x22<>|%]+(#|\?|$) [nocase]
66 RewriteRule . - [forbidden]
77 </IfModule>
Index: branches/REL1_17/phase3/includes/User.php
@@ -905,24 +905,25 @@
906906 return false;
907907 }
908908
909 - $this->mId = $sId;
910 - if ( !$this->loadFromId() ) {
911 - # Not a valid ID, loadFromId has switched the object to anon for us
 909+ $proposedUser = User::newFromId( $sId );
 910+ if ( !$proposedUser->isLoggedIn() ) {
 911+ # Not a valid ID
 912+ $this->loadDefaults();
912913 return false;
913914 }
914915
915916 global $wgBlockDisablesLogin;
916 - if( $wgBlockDisablesLogin && $this->isBlocked() ) {
 917+ if( $wgBlockDisablesLogin && $proposedUser->isBlocked() ) {
917918 # User blocked and we've disabled blocked user logins
918919 $this->loadDefaults();
919920 return false;
920921 }
921922
922923 if ( isset( $_SESSION['wsToken'] ) ) {
923 - $passwordCorrect = $_SESSION['wsToken'] == $this->mToken;
 924+ $passwordCorrect = $proposedUser->getToken() === $_SESSION['wsToken'];
924925 $from = 'session';
925926 } else if ( $wgRequest->getCookie( 'Token' ) !== null ) {
926 - $passwordCorrect = $this->mToken == $wgRequest->getCookie( 'Token' );
 927+ $passwordCorrect = $proposedUser->getToken() === $wgRequest->getCookie( 'Token' );
927928 $from = 'cookie';
928929 } else {
929930 # No session or persistent login cookie
@@ -930,7 +931,8 @@
931932 return false;
932933 }
933934
934 - if ( ( $sName == $this->mName ) && $passwordCorrect ) {
 935+ if ( ( $sName === $proposedUser->getName() ) && $passwordCorrect ) {
 936+ $this->loadFromUserObject( $proposedUser );
935937 $_SESSION['wsToken'] = $this->mToken;
936938 wfDebug( "User: logged in from $from\n" );
937939 return true;
@@ -943,6 +945,18 @@
944946 }
945947
946948 /**
 949+ * Load the data for this user object from another user object.
 950+ */
 951+ protected function loadFromUserObject( $user ) {
 952+ $user->load();
 953+ $user->loadGroups();
 954+ $user->loadOptions();
 955+ foreach ( self::$mCacheVars as $var ) {
 956+ $this->$var = $user->$var;
 957+ }
 958+ }
 959+
 960+ /**
947961 * Load user and user_group data from the database.
948962 * $this::mId must be set, this is how the user is identified.
949963 *
Index: branches/REL1_17/phase3/includes/WebRequest.php
@@ -755,7 +755,7 @@
756756 global $wgScriptExtension;
757757
758758 if ( isset( $_SERVER['QUERY_STRING'] )
759 - && preg_match( '/\.[a-z0-9]{1,4}(#|\?|$)/i', $_SERVER['QUERY_STRING'] ) )
 759+ && preg_match( '/\.[^\\/:*?"<>|%]+(#|\?|$)/i', $_SERVER['QUERY_STRING'] ) )
760760 {
761761 // Bug 28235
762762 // Block only Internet Explorer, and requests with missing UA
Index: branches/REL1_17/phase3/img_auth.php
@@ -39,7 +39,7 @@
4040
4141 // Check for bug 28235: QUERY_STRING overriding the correct extension
4242 if ( isset( $_SERVER['QUERY_STRING'] )
43 - && preg_match( '/\.[a-z0-9]{1,4}(#|\?|$)/i', $_SERVER['QUERY_STRING'] ) )
 43+ && preg_match( '/\.[^\\/:*?"<>|%]+(#|\?|$)/i', $_SERVER['QUERY_STRING'] ) )
4444 {
4545 wfForbidden( 'img-auth-accessdenied', 'img-auth-bad-query-string' );
4646 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r87484* Fix for bug 28534: IE 6 content type detection again...tstarling05:33, 5 May 2011
r87486Merged r87483 from REL1_17: security fixeststarling05:47, 5 May 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r87482* Fix for bug 28534: IE 6 content type detection again...tstarling05:29, 5 May 2011

Status & tagging log