X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiCheckToken.php;h=480915e60cf880a613c46073ba78391259e44485;hb=4d38a489b075fbd0a4c9ec228f83295cf9b9c5fc;hp=3d2159cf50b36bf0c6cf60d7080c73c390ea7f3e;hpb=3071f1fad720f1773864621158a0c59b73124896;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiCheckToken.php b/includes/api/ApiCheckToken.php index 3d2159cf50..480915e60c 100644 --- a/includes/api/ApiCheckToken.php +++ b/includes/api/ApiCheckToken.php @@ -22,6 +22,8 @@ * @file */ +use MediaWiki\Session\Token; + /** * @since 1.25 * @ingroup API @@ -39,6 +41,11 @@ class ApiCheckToken extends ApiBase { $tokenObj = ApiQueryTokens::getToken( $this->getUser(), $this->getRequest()->getSession(), $salts[$params['type']] ); + + if ( substr( $token, -strlen( urldecode( Token::SUFFIX ) ) ) === urldecode( Token::SUFFIX ) ) { + $this->addWarning( 'apiwarn-checktoken-percentencoding' ); + } + if ( $tokenObj->match( $token, $maxage ) ) { $res['result'] = 'valid'; } elseif ( $maxage !== null && $tokenObj->match( $token ) ) { @@ -47,7 +54,7 @@ class ApiCheckToken extends ApiBase { $res['result'] = 'invalid'; } - $ts = MediaWiki\Session\Token::getTimestamp( $token ); + $ts = Token::getTimestamp( $token ); if ( $ts !== null ) { $mwts = new MWTimestamp(); $mwts->timestamp->setTimestamp( $ts ); @@ -66,6 +73,7 @@ class ApiCheckToken extends ApiBase { 'token' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true, + ApiBase::PARAM_SENSITIVE => true, ], 'maxtokenage' => [ ApiBase::PARAM_TYPE => 'integer',