Supporting each other

Community forums

Welcome, Guest
Username: Password: Remember me
Report any technical problems you discover and discuss solutions.
  • Page:
  • 1

TOPIC:

v3: bug file mime type check 9 years 3 months ago #3054

  • jayaich
  • jayaich's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 82
  • Thank you received: 5
Hello,

The file MIME type check has a bug in which two errors could be produced. The code shows:
                $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:
--- 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.

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

Last edit: by jayaich.
  • Page:
  • 1
Moderators: ronmjultenJohnSmith
Time to create page: 0.046 seconds
Copyright © 2024 The Xerte Project.
Xerte logo Apereo logo OSI Logo

Search