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 Linux file extension check 9 years 3 months ago #3048

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

Under Linux/UNIX file extensions (suffix) do not necessarily have any specific meaning. It is perfectly acceptable for a file to have no extension. The current file extension check requires filenames to have an extension on them, and this should not be the case. Files with no extension should just be accepted. Any file without an extension still has to pass the MIME type check before it is accepted.
Secondly, the current extension check makes us of the PHP 'empty' function. This, however, would see a file extension of '0' (a zero) as being false, and hence a file of 'abc.0' would be rejected. A better test is to check the extension length. A patch for this is below:
--- library/Xerte/Validate/FileExtension.php.orig       2015-07-29 23:17:23.000000000 +0100
+++ library/Xerte/Validate/FileExtension.php    2015-08-20 10:53:41.182463794 +0100
@@ -41,10 +41,8 @@
         _debug($blacklist);
         _debug($extension);
 
-        if (empty($extension)) {
-            _debug("File extension not found for '$filename'.");
-            $this->messages['NO_EXTENSION'] = "File extension not found.";
-            return false;
+        if (!strlen($extension)) {
+            return true;
         }
 
         if (in_array($extension, $blacklist)) {

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

  • Page:
  • 1
Moderators: ronmjultenJohnSmith
Time to create page: 0.045 seconds
Copyright © 2024 The Xerte Project.
Xerte logo Apereo logo OSI Logo

Search