From: Brad Jorsch Date: Sun, 16 Dec 2012 22:45:31 +0000 (-0500) Subject: (bug 43177) API: Fix regression in case handling for sha1 params X-Git-Tag: 1.31.0-rc.0~21275^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/bilan.php?a=commitdiff_plain;h=f2383b216efad6a9e19492c6cae41911163528f0;p=lhc%2Fweb%2Fwiklou.git (bug 43177) API: Fix regression in case handling for sha1 params While the change in Ic980fd71 makes sense since MediaWiki stores the hashes with lowercase letters, historically aisha1 and fasha1 accepted both upper and lowercase because wfBaseConvert accepts both. To avoid a backwards compatibility break, let's adjust the code to explicitly lowercase the input for those parameters. And for good measure, let's also accept both cases for the corresponding sha1base36 parameters. Change-Id: I704935193398c722c22a302dc9d23f2c0e2e3e39 --- diff --git a/includes/api/ApiQueryAllImages.php b/includes/api/ApiQueryAllImages.php index e6a0194607..2319263dcf 100644 --- a/includes/api/ApiQueryAllImages.php +++ b/includes/api/ApiQueryAllImages.php @@ -175,12 +175,13 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { $sha1 = false; if ( isset( $params['sha1'] ) ) { - if ( !$this->validateSha1Hash( $params['sha1'] ) ) { + $sha1 = strtolower( $params['sha1'] ); + if ( !$this->validateSha1Hash( $sha1 ) ) { $this->dieUsage( 'The SHA1 hash provided is not valid', 'invalidsha1hash' ); } - $sha1 = wfBaseConvert( $params['sha1'], 16, 36, 31 ); + $sha1 = wfBaseConvert( $sha1, 16, 36, 31 ); } elseif ( isset( $params['sha1base36'] ) ) { - $sha1 = $params['sha1base36']; + $sha1 = strtolower( $params['sha1base36'] ); if ( !$this->validateSha1Base36Hash( $sha1 ) ) { $this->dieUsage( 'The SHA1Base36 hash provided is not valid', 'invalidsha1base36hash' ); } diff --git a/includes/api/ApiQueryFilearchive.php b/includes/api/ApiQueryFilearchive.php index dbca1d96db..7ec47fa91f 100644 --- a/includes/api/ApiQueryFilearchive.php +++ b/includes/api/ApiQueryFilearchive.php @@ -103,15 +103,16 @@ class ApiQueryFilearchive extends ApiQueryBase { if ( $sha1Set || $sha1base36Set ) { $sha1 = false; if ( $sha1Set ) { - if ( !$this->validateSha1Hash( $params['sha1'] ) ) { + $sha1 = strtolower( $params['sha1'] ); + if ( !$this->validateSha1Hash( $sha1 ) ) { $this->dieUsage( 'The SHA1 hash provided is not valid', 'invalidsha1hash' ); } - $sha1 = wfBaseConvert( $params['sha1'], 16, 36, 31 ); + $sha1 = wfBaseConvert( $sha1, 16, 36, 31 ); } elseif ( $sha1base36Set ) { - if ( !$this->validateSha1Base36Hash( $params['sha1base36'] ) ) { + $sha1 = strtolower( $params['sha1base36'] ); + if ( !$this->validateSha1Base36Hash( $sha1 ) ) { $this->dieUsage( 'The SHA1Base36 hash provided is not valid', 'invalidsha1base36hash' ); } - $sha1 = $params['sha1base36']; } if ( $sha1 ) { $this->addWhereFld( 'fa_sha1', $sha1 );