Report any technical problems you discover and discuss solutions.

v3: bug file mime type check

Plus d'informations
il y a 10 ans 11 mois - il y a 10 ans 11 mois #3054 par jayaich
v3: bug file mime type check a été créé par 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.
Dernière édition: il y a 10 ans 11 mois par jayaich.

Connexion ou Créer un compte pour participer à la conversation.

Modérateurs: ronmjultenJohnSmith
Temps de génération de la page : 0.133 secondes
Copyright © 2026 The Xerte Project.
Xerte logo Apereo logo OSI Logo