r89576 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89575‎ | r89576 | r89577 >
Date:16:06, 6 June 2011
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
Followup r89542, validate hashes
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryFilearchive.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryFilearchive.php
@@ -95,8 +95,14 @@
9696
9797 $sha1 = false;
9898 if ( $sha1Set ) {
 99+ if ( !ApiQueryAllimages::validateSha1Hash( $params['sha1'] ) ) {
 100+ $this->dieUsage( 'The SHA1 hash provided is not valid', 'invalidsha1hash' );
 101+ }
99102 $sha1 = wfBaseConvert( $params['sha1'], 16, 36, 31 );
100103 } elseif ( $sha1base36Set ) {
 104+ if ( !ApiQueryAllimages::validateSha1Base36Hash( $sha1 ) ) {
 105+ $this->dieUsage( 'The SHA1Base36 hash provided is not valid', 'invalidsha1base36hash' );
 106+ }
101107 $sha1 = $params['sha1base36'];
102108 }
103109 if ( $sha1 ) {
@@ -274,6 +280,8 @@
275281 return array_merge( parent::getPossibleErrors(), array(
276282 array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted file information' ),
277283 array( 'code' => 'hashsearchdisabled', 'info' => 'Search by hash disabled in Miser Mode' ),
 284+ array( 'code' => 'invalidsha1hash', 'info' => 'The SHA1 hash provided is not valid' ),
 285+ array( 'code' => 'invalidsha1base36hash', 'info' => 'The SHA1Base36 hash provided is not valid' ),
278286 ) );
279287 }
280288

Follow-up revisions

RevisionCommit summaryAuthorDate
r90751Followup r89576, and other related revisions...reedy03:50, 25 June 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89542* (bug 21346) Make deleted images searchable by hash (disabled in Miser Mode)...reedy23:40, 5 June 2011

Comments

#Comment by Bryan (talk | contribs)   08:32, 7 June 2011

ApiQueryAllimages seems to be a rather arbitrary place for validateSha1Base36Hash(). Isn't ApiQueryBase or ApiBase a better location?

#Comment by Reedy (talk | contribs)   09:08, 7 June 2011

Indeed

Well, tbh, we should probably move the whole validation bit up a level or 2, and move the actual validation routines to somewhere in the file/similar classes

#Comment by Reedy (talk | contribs)   09:10, 7 June 2011

But of course, they were put there originally, as that was the only place using them at the time

#Comment by Aaron Schulz (talk | contribs)   21:50, 24 June 2011

Yeah, these functions should be moved up.

Status & tagging log