r87486 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87485‎ | r87486 | r87487 >
Date:05:47, 5 May 2011
Author:tstarling
Status:ok
Tags:
Comment:
Merged r87483 from REL1_17: security fixes
Modified paths:
  • /branches/wmf/1.17wmf1/img_auth.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/User.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/WebRequest.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/includes/User.php
@@ -902,24 +902,25 @@
903903 return false;
904904 }
905905
906 - $this->mId = $sId;
907 - if ( !$this->loadFromId() ) {
908 - # Not a valid ID, loadFromId has switched the object to anon for us
 906+ $proposedUser = User::newFromId( $sId );
 907+ if ( !$proposedUser->isLoggedIn() ) {
 908+ # Not a valid ID
 909+ $this->loadDefaults();
909910 return false;
910911 }
911912
912913 global $wgBlockDisablesLogin;
913 - if( $wgBlockDisablesLogin && $this->isBlocked() ) {
 914+ if( $wgBlockDisablesLogin && $proposedUser->isBlocked() ) {
914915 # User blocked and we've disabled blocked user logins
915916 $this->loadDefaults();
916917 return false;
917918 }
918919
919920 if ( isset( $_SESSION['wsToken'] ) ) {
920 - $passwordCorrect = $_SESSION['wsToken'] == $this->mToken;
 921+ $passwordCorrect = $proposedUser->getToken() === $_SESSION['wsToken'];
921922 $from = 'session';
922923 } else if ( $wgRequest->getCookie( 'Token' ) !== null ) {
923 - $passwordCorrect = $this->mToken == $wgRequest->getCookie( 'Token' );
 924+ $passwordCorrect = $proposedUser->getToken() === $wgRequest->getCookie( 'Token' );
924925 $from = 'cookie';
925926 } else {
926927 # No session or persistent login cookie
@@ -927,7 +928,8 @@
928929 return false;
929930 }
930931
931 - if ( ( $sName == $this->mName ) && $passwordCorrect ) {
 932+ if ( ( $sName === $proposedUser->getName() ) && $passwordCorrect ) {
 933+ $this->loadFromUserObject( $proposedUser );
932934 $_SESSION['wsToken'] = $this->mToken;
933935 wfDebug( "User: logged in from $from\n" );
934936 return true;
@@ -940,6 +942,18 @@
941943 }
942944
943945 /**
 946+ * Load the data for this user object from another user object.
 947+ */
 948+ protected function loadFromUserObject( $user ) {
 949+ $user->load();
 950+ $user->loadGroups();
 951+ $user->loadOptions();
 952+ foreach ( self::$mCacheVars as $var ) {
 953+ $this->$var = $user->$var;
 954+ }
 955+ }
 956+
 957+ /**
944958 * Load user and user_group data from the database.
945959 * $this::mId must be set, this is how the user is identified.
946960 *
Property changes on: branches/wmf/1.17wmf1/includes/User.php
___________________________________________________________________
Modified: svn:mergeinfo
947961 Merged /branches/REL1_17/phase3/includes/User.php:r87483
Index: branches/wmf/1.17wmf1/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
Property changes on: branches/wmf/1.17wmf1/includes/WebRequest.php
___________________________________________________________________
Modified: svn:mergeinfo
763763 Merged /branches/REL1_17/phase3/includes/WebRequest.php:r87483
Index: branches/wmf/1.17wmf1/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 }
Property changes on: branches/wmf/1.17wmf1/img_auth.php
___________________________________________________________________
Modified: svn:mergeinfo
4747 Merged /branches/REL1_17/phase3/img_auth.php:r87483

Past revisions this follows-up on

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

Status & tagging log