From: Szymon Świerkosz Date: Sun, 15 Apr 2012 17:40:20 +0000 (+0100) Subject: Fix gettoken loophole from https://gerrit.wikimedia.org/r/#change,4220 X-Git-Tag: 1.31.0-rc.0~23909 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=d66a00d8f3806d78b5de0959fcaa9bd52e4d6e94;p=lhc%2Fweb%2Fwiklou.git Fix gettoken loophole from https://gerrit.wikimedia.org/r/#change,4220 Reported and patch by Szymon Świerkosz/Beau Change-Id: I3b5a001ad60e7e637b351331794cb275a7cf021a --- diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 2105b811b9..8c035dcd12 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -595,8 +595,14 @@ class ApiMain extends ApiBase { $moduleParams = $module->extractRequestParams(); // Die if token required, but not provided (unless there is a gettoken parameter) + if ( isset( $moduleParams['gettoken'] ) ) { + $gettoken = $moduleParams['gettoken']; + } else { + $gettoken = false; + } + $salt = $module->getTokenSalt(); - if ( $salt !== false && isset( $moduleParams['gettoken'] ) && !$moduleParams['gettoken'] ) { + if ( $salt !== false && !$gettoken ) { if ( !isset( $moduleParams['token'] ) ) { $this->dieUsageMsg( array( 'missingparam', 'token' ) ); } else {