]> git.agnieray.net Git - galette.git/commitdiff
Allow 1 char filename; fixes #1028 0.8.3.4
authorJohan Cwiklinski <johan@x-tnd.be>
Thu, 18 May 2017 04:58:49 +0000 (06:58 +0200)
committerJohan Cwiklinski <johan@x-tnd.be>
Thu, 18 May 2017 04:58:49 +0000 (06:58 +0200)
galette/lib/Galette/Core/Picture.php
galette/lib/Galette/IO/FileTrait.php

index 25643fd93bdc2b72f5748195ea51af9f034c404f..99eede5f91bf2c55f943a551594d4138602309b1 100644 (file)
@@ -401,7 +401,7 @@ class Picture implements FileInterface
         $tmpfile = $file['tmp_name'];
 
         //First, does the file have a valid name?
-        $reg = "/^(.[^" . implode('', $this->bad_chars) . "]+)\.(" .
+        $reg = "/^([^" . implode('', $this->bad_chars) . "]+)\.(" .
             implode('|', $this->allowed_extensions) . ")$/i";
         if ( preg_match($reg, $name, $matches) ) {
             Analog::log(
@@ -415,7 +415,7 @@ class Picture implements FileInterface
                 $extension = 'jpg';
             }
         } else {
-            $erreg = "/^(.[^" . implode('', $this->bad_chars) . "]+)\.(.*)/i";
+            $erreg = "/^([^" . implode('', $this->bad_chars) . "]+)\.(.*)/i";
             $m = preg_match($erreg, $name, $errmatches);
 
             $err_msg = '[' . $class . '] ';
index 5732a74c53612245226b5d3e4b8f27ceb5b81e62..cfb4428f9c6b3bd88efb624a64efb3d4a0de98d4 100644 (file)
@@ -245,7 +245,7 @@ trait FileTrait
         $tmpfile = $file['tmp_name'];
 
         //First, does the file have a valid name?
-        $reg = "/^(.[^" . implode('', $this->bad_chars) . "]+)\.";
+        $reg = "/^([^" . implode('', $this->bad_chars) . "]+)\.";
         if ( count($this->allowed_extensions) > 0 ) {
             $reg .= "(" . implode('|', $this->allowed_extensions) . ")";
         } else {
@@ -259,7 +259,7 @@ trait FileTrait
             );
             $extension = strtolower($matches[2]);
         } else {
-            $erreg = "/^(.[^" . implode('', $this->bad_chars) . "]+)\.(.*)/i";
+            $erreg = "/^([^" . implode('', $this->bad_chars) . "]+)\.(.*)/i";
             $m = preg_match($erreg, $this->name, $errmatches);
 
             $err_msg = '[' . $class . '] ';
@@ -388,11 +388,7 @@ trait FileTrait
      */
     public function getBadChars()
     {
-        $ret = '';
-        foreach ( $this->bad_chars as $char=>$regchar ) {
-            $ret .= '`' . $char . '`, ';
-        }
-        return $ret;
+        return '`' . implode('`, `', array_keys($this->bad_chars)) . '`';
     }
 
     /**