Commits

Gfy  committed 814cab7

no leading or trailing spaces with renames

  • Participants
  • Parent commits ac25dac

Comments (0)

Files changed (1)

  * LGPLv3 with Affero clause (LAGPL)
  * See http://mo.morsi.org/blog/node/270
  * rescene.php written on 2011-07-27
- * Last version: 2013-01-05
+ * Last version: 2013-01-14
  *
  * Features:
  *  - process a SRR file which returns:
  * No // (double forward slashes).
  * The string cannot start with a /.
  * The string must contain at least one character.
+ * The string cannot start or end with a space.
  */
 function fileNameCheck($path) {
-    return preg_match('/([\\\\:*?"<>|]|\/\/)|^\/|^$/', $path);
+    return preg_match('/([\\\\:*?"<>|]|\/\/)|^\/|^$|^ .*|^.* $/', $path);
 }
 
 function fileNameCheckTest() {
             fileNameCheck('dir\\\\file.ext') &&
             fileNameCheck('/dir/file.ext') &&
             fileNameCheck('') &&
-            fileNameCheck('dir\\file.ext'));
+            fileNameCheck('dir\\file.ext') &&
+            fileNameCheck(' dir/file.ext') &&
+            fileNameCheck('dir/file.ext '));
 }
 
 /**