From cb77d12c7074d9653f28dc83573fa97d8677222e Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Sat, 26 Apr 2008 14:09:16 +0000 Subject: [PATCH] API: Fixed handling of usernames containing spaces in list=block --- RELEASE-NOTES | 1 + includes/api/ApiQueryBlocks.php | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 824288a788..6a644e10c7 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -266,6 +266,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * action=login now returns the correct waiting time in the details property * (bug 13792) Broken titles are now silently skipped in search results. * (bug 13819) exturlusage paging skipped an item +* Fixed handling of usernames containing spaces in list=block === Languages updated in 1.13 === diff --git a/includes/api/ApiQueryBlocks.php b/includes/api/ApiQueryBlocks.php index 7d85dd3578..795c350a00 100644 --- a/includes/api/ApiQueryBlocks.php +++ b/includes/api/ApiQueryBlocks.php @@ -34,6 +34,8 @@ if (!defined('MEDIAWIKI')) { * @addtogroup API */ class ApiQueryBlocks extends ApiQueryBase { + + var $users; public function __construct($query, $moduleName) { parent :: __construct($query, $moduleName, 'bk'); @@ -89,7 +91,11 @@ class ApiQueryBlocks extends ApiQueryBase { if(isset($params['ids'])) $this->addWhere(array('ipb_id' => $params['ids'])); if(isset($params['users'])) - $this->addWhere(array('ipb_address' => $params['users'])); + { + foreach((array)$params['users'] as $u) + $this->prepareUsername($u); + $this->addWhere(array('ipb_address' => $this->usernames)); + } if(!$wgUser->isAllowed('suppress')) $this->addWhere(array('ipb_deleted' => 0)); @@ -152,6 +158,21 @@ class ApiQueryBlocks extends ApiQueryBase { $result->setIndexedTagName($data, 'block'); $result->addValue('query', $this->getModuleName(), $data); } + + protected function prepareUsername($user) { + if( $user ) { + $name = User::isIP( $user ) + ? $user + : User::getCanonicalName( $user, 'valid' ); + if( $name === false ) { + $this->dieUsage( "User name {$user} is not valid", 'param_user' ); + } else { + $this->usernames[] = $name; + } + } else { + $this->dieUsage( 'User parameter may not be empty', 'param_user' ); + } + } protected function convertHexIP($ip) { -- 2.20.1