Index: trunk/phase3/includes/api/ApiQueryBase.php |
— | — | @@ -514,6 +514,22 @@ |
515 | 515 | } |
516 | 516 | |
517 | 517 | /** |
| 518 | + * @param $hash string |
| 519 | + * @return bool |
| 520 | + */ |
| 521 | + public function validateSha1Hash( $hash ) { |
| 522 | + return preg_match( '/[a-fA-F0-9]{40}/', $hash ); |
| 523 | + } |
| 524 | + |
| 525 | + /** |
| 526 | + * @param $hash string |
| 527 | + * @return bool |
| 528 | + */ |
| 529 | + public function validateSha1Base36Hash( $hash ) { |
| 530 | + return preg_match( '/[a-zA-Z0-9]{31}/', $hash ); |
| 531 | + } |
| 532 | + |
| 533 | + /** |
518 | 534 | * @return array |
519 | 535 | */ |
520 | 536 | public function getPossibleErrors() { |
Index: trunk/phase3/includes/api/ApiQueryFilearchive.php |
— | — | @@ -95,12 +95,12 @@ |
96 | 96 | |
97 | 97 | $sha1 = false; |
98 | 98 | if ( $sha1Set ) { |
99 | | - if ( !ApiQueryAllimages::validateSha1Hash( $params['sha1'] ) ) { |
| 99 | + if ( !$this->validateSha1Hash( $params['sha1'] ) ) { |
100 | 100 | $this->dieUsage( 'The SHA1 hash provided is not valid', 'invalidsha1hash' ); |
101 | 101 | } |
102 | 102 | $sha1 = wfBaseConvert( $params['sha1'], 16, 36, 31 ); |
103 | 103 | } elseif ( $sha1base36Set ) { |
104 | | - if ( !ApiQueryAllimages::validateSha1Base36Hash( $params['sha1base36'] ) ) { |
| 104 | + if ( !$this->validateSha1Base36Hash( $params['sha1base36'] ) ) { |
105 | 105 | $this->dieUsage( 'The SHA1Base36 hash provided is not valid', 'invalidsha1base36hash' ); |
106 | 106 | } |
107 | 107 | $sha1 = $params['sha1base36']; |
Index: trunk/phase3/includes/api/ApiQueryAllimages.php |
— | — | @@ -109,13 +109,13 @@ |
110 | 110 | |
111 | 111 | $sha1 = false; |
112 | 112 | if ( isset( $params['sha1'] ) ) { |
113 | | - if ( !self::validateSha1Hash( $params['sha1'] ) ) { |
| 113 | + if ( !$this->validateSha1Hash( $params['sha1'] ) ) { |
114 | 114 | $this->dieUsage( 'The SHA1 hash provided is not valid', 'invalidsha1hash' ); |
115 | 115 | } |
116 | 116 | $sha1 = wfBaseConvert( $params['sha1'], 16, 36, 31 ); |
117 | 117 | } elseif ( isset( $params['sha1base36'] ) ) { |
118 | 118 | $sha1 = $params['sha1base36']; |
119 | | - if ( !self::validateSha1Base36Hash( $sha1 ) ) { |
| 119 | + if ( !$this->validateSha1Base36Hash( $sha1 ) ) { |
120 | 120 | $this->dieUsage( 'The SHA1Base36 hash provided is not valid', 'invalidsha1base36hash' ); |
121 | 121 | } |
122 | 122 | } |
— | — | @@ -181,22 +181,6 @@ |
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | | - /** |
186 | | - * @param $hash string |
187 | | - * @return bool |
188 | | - */ |
189 | | - public static function validateSha1Hash( $hash ) { |
190 | | - return preg_match( '/[a-fA-F0-9]{40}/', $hash ); |
191 | | - } |
192 | | - |
193 | | - /** |
194 | | - * @param $hash string |
195 | | - * @return bool |
196 | | - */ |
197 | | - public static function validateSha1Base36Hash( $hash ) { |
198 | | - return preg_match( '/[a-zA-Z0-9]{31}/', $hash ); |
199 | | - } |
200 | | - |
201 | 185 | public function getAllowedParams() { |
202 | 186 | return array ( |
203 | 187 | 'from' => null, |