Report any technical problems you discover and discuss solutions.

v3: bug Linux file extension check

Plus d'informations
il y a 10 ans 11 mois #3048 par jayaich
v3: bug Linux file extension check a été créé par 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)) {

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

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