Report any technical problems you discover and discuss solutions.

v3: bug Linux file extension check

  • jayaich
  • Onderwerp Auteur
  • Offline
  • Premium lid
  • Premium lid
Meer
10 jaren 11 maanden geleden #3048 door jayaich
v3: bug Linux file extension check werd gestart door jayaich
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:
Code:
--- 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)) {

Graag Inloggen of een account aanmaken deelnemen aan het gesprek.

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