Report any technical problems you discover and discuss solutions.

v3: bug file mime type check

  • jayaich
  • Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 11 months ago - 10 years 11 months ago #3054 by jayaich
v3: bug file mime type check was created by 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.
Last edit: 10 years 11 months ago by jayaich.

Please Log in or Create an account to join the conversation.

Moderators: ronmjultenJohnSmith
Time to create page: 0.134 seconds
Copyright © 2026 The Xerte Project.
Xerte logo Apereo logo OSI Logo