Report any technical problems you discover and discuss solutions.

v3: bug file mime type check

  • jayaich
  • Onderwerp Auteur
  • Offline
  • Premium lid
  • Premium lid
Meer
10 jaren 11 maanden geleden - 10 jaren 11 maanden geleden #3054 door jayaich
v3: bug file mime type check werd gestart door jayaich
Hello,

The file MIME type check has a bug in which two errors could be produced. The code shows:
Code:
$this->messages['INVALID_MIME_TYPE'] = "$mime_type is not in list of allowable types"; } $this->messages['FILE_NOT_FOUND'] = "File not found - $file_name";
So an invalid mime type error is recorded, and then the file not found one is recorded too. Basically the 'else' statement is missing from the 'if' statement'. A patch for this is below:
Code:
--- library/Xerte/Validate/FileMimeType.php.orig 2015-07-29 23:17:23.000000000 +0100 +++ library/Xerte/Validate/FileMimeType.php 2015-08-19 00:06:15.258614703 +0100 @@ -46,9 +46,12 @@ if(in_array($mime_type, self::$allowableMimeTypeList)) { return true; } + error_log("Invalid MIME type found in {$file_name}: $mime_type"); $this->messages['INVALID_MIME_TYPE'] = "$mime_type is not in list of allowable types"; } - $this->messages['FILE_NOT_FOUND'] = "File not found - $file_name"; + else { + $this->messages['FILE_NOT_FOUND'] = "File not found - $file_name"; + } } else { $this->messages['UNSUPPORTED'] = "Can't run - function: mime_content_type not found";

I included an error_log statement into the patch because I found it useful to log the file name and the mime type when an invalid one was found.



John.
Laatst bewerkt 10 jaren 11 maanden geleden door jayaich.

Graag Inloggen of een account aanmaken deelnemen aan het gesprek.

Moderators: ronmjultenJohnSmith
Tijd voor maken pagina: 0.258 seconden
Copyright © 2026 The Xerte Project.
Xerte logo Apereo logo OSI Logo