http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90751

Revision: 90751
Author:   reedy
Date:     2011-06-25 03:50:41 +0000 (Sat, 25 Jun 2011)
Log Message:
-----------
Followup r89576, and other related revisions

Move SHA1 has validation functions in ApiQueryBase

Modified Paths:
--------------
    trunk/phase3/includes/api/ApiQueryAllimages.php
    trunk/phase3/includes/api/ApiQueryBase.php
    trunk/phase3/includes/api/ApiQueryFilearchive.php

Modified: trunk/phase3/includes/api/ApiQueryAllimages.php
===================================================================
--- trunk/phase3/includes/api/ApiQueryAllimages.php     2011-06-25 02:55:14 UTC 
(rev 90750)
+++ trunk/phase3/includes/api/ApiQueryAllimages.php     2011-06-25 03:50:41 UTC 
(rev 90751)
@@ -109,13 +109,13 @@
 
                $sha1 = false;
                if ( isset( $params['sha1'] ) ) {
-                       if ( !self::validateSha1Hash( $params['sha1'] ) ) {
+                       if ( !$this->validateSha1Hash( $params['sha1'] ) ) {
                                $this->dieUsage( 'The SHA1 hash provided is not 
valid', 'invalidsha1hash' );
                        }
                        $sha1 = wfBaseConvert( $params['sha1'], 16, 36, 31 );
                } elseif ( isset( $params['sha1base36'] ) ) {
                        $sha1 = $params['sha1base36'];
-                       if ( !self::validateSha1Base36Hash( $sha1 ) ) {
+                       if ( !$this->validateSha1Base36Hash( $sha1 ) ) {
                                $this->dieUsage( 'The SHA1Base36 hash provided 
is not valid', 'invalidsha1base36hash' );
                        }
                }
@@ -181,22 +181,6 @@
                }
        }
 
-       /**
-        * @param $hash string
-        * @return bool
-        */
-       public static function validateSha1Hash( $hash ) {
-               return preg_match( '/[a-fA-F0-9]{40}/', $hash );
-       }
-
-       /**
-        * @param $hash string
-        * @return bool
-        */
-       public static function validateSha1Base36Hash( $hash ) {
-               return preg_match( '/[a-zA-Z0-9]{31}/', $hash );
-       }
-
        public function getAllowedParams() {
                return array (
                        'from' => null,

Modified: trunk/phase3/includes/api/ApiQueryBase.php
===================================================================
--- trunk/phase3/includes/api/ApiQueryBase.php  2011-06-25 02:55:14 UTC (rev 
90750)
+++ trunk/phase3/includes/api/ApiQueryBase.php  2011-06-25 03:50:41 UTC (rev 
90751)
@@ -514,6 +514,22 @@
        }
 
        /**
+        * @param $hash string
+        * @return bool
+        */
+       public function validateSha1Hash( $hash ) {
+               return preg_match( '/[a-fA-F0-9]{40}/', $hash );
+       }
+
+       /**
+        * @param $hash string
+        * @return bool
+        */
+       public function validateSha1Base36Hash( $hash ) {
+               return preg_match( '/[a-zA-Z0-9]{31}/', $hash );
+       }
+
+       /**
         * @return array
         */
        public function getPossibleErrors() {

Modified: trunk/phase3/includes/api/ApiQueryFilearchive.php
===================================================================
--- trunk/phase3/includes/api/ApiQueryFilearchive.php   2011-06-25 02:55:14 UTC 
(rev 90750)
+++ trunk/phase3/includes/api/ApiQueryFilearchive.php   2011-06-25 03:50:41 UTC 
(rev 90751)
@@ -95,12 +95,12 @@
 
                        $sha1 = false;
                        if ( $sha1Set ) {
-                               if ( !ApiQueryAllimages::validateSha1Hash( 
$params['sha1'] ) ) {
+                               if ( !$this->validateSha1Hash( $params['sha1'] 
) ) {
                                        $this->dieUsage( 'The SHA1 hash 
provided is not valid', 'invalidsha1hash' );
                                }
                                $sha1 = wfBaseConvert( $params['sha1'], 16, 36, 
31 );
                        } elseif ( $sha1base36Set ) {
-                               if ( 
!ApiQueryAllimages::validateSha1Base36Hash( $params['sha1base36'] ) ) {
+                               if ( !$this->validateSha1Base36Hash( 
$params['sha1base36'] ) ) {
                                        $this->dieUsage( 'The SHA1Base36 hash 
provided is not valid', 'invalidsha1base36hash' );
                                }
                                $sha1 = $params['sha1base36'];


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to