From: jenkins-bot Date: Thu, 21 Dec 2017 19:01:05 +0000 (+0000) Subject: Merge "ApiBlock: Improve username validation" X-Git-Tag: 1.31.0-rc.0~1142 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=e986b7e423d55f6e764564a12a3db8382f7385eb;hp=c9092317b33aa3178de805dd73b692d12c8a9a6e Merge "ApiBlock: Improve username validation" --- diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php index 4d37af3162..366a6df98f 100644 --- a/includes/api/ApiBlock.php +++ b/includes/api/ApiBlock.php @@ -67,12 +67,12 @@ class ApiBlock extends ApiBase { $params['user'] = $username; } } else { - $target = User::newFromName( $params['user'] ); + list( $target, $type ) = SpecialBlock::getTargetAndType( $params['user'] ); // T40633 - if the target is a user (not an IP address), but it // doesn't exist or is unusable, error. - if ( $target instanceof User && - ( $target->isAnon() /* doesn't exist */ || !User::isUsableName( $target->getName() ) ) + if ( $type === Block::TYPE_USER && + ( $target->isAnon() /* doesn't exist */ || !User::isUsableName( $params['user'] ) ) ) { $this->dieWithError( [ 'nosuchusershort', $params['user'] ], 'nosuchuser' ); }