[BUGFIX] t3lib_div::validPathStr() fails on certain file names
authorDmitry Dulepov <dmitry@typo3.org>
Fri, 2 Dec 2011 15:22:56 +0000 (17:22 +0200)
committerTolleiv Nietsch <info@tolleiv.de>
Sat, 14 Jan 2012 11:38:34 +0000 (12:38 +0100)
Function t3lib_div::validPathStr() fails on file names with Unicode
characters. Adding 'u' modifier to the regular expression solves
the problem.

Change-Id: I9dfb31090d12133798f4e8d47e7394e6c7be51a6
Resolves: #32046
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/7032
Reviewed-by: Oliver Klee
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
Reviewed-by: Stefan Neufeind
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
t3lib/class.t3lib_div.php
tests/t3lib/class.t3lib_divTest.php

index 7e8970c..242f41f 100644 (file)
@@ -3843,7 +3843,7 @@ final class t3lib_div {
         * @todo Possible improvement: Should it rawurldecode the string first to check if any of these characters is encoded?
         */
        public static function validPathStr($theFile) {
-               if (strpos($theFile, '//') === FALSE && strpos($theFile, '\\') === FALSE && !preg_match('#(?:^\.\.|/\.\./|[[:cntrl:]])#', $theFile)) {
+               if (strpos($theFile, '//') === FALSE && strpos($theFile, '\\') === FALSE && !preg_match('#(?:^\.\.|/\.\./|[[:cntrl:]])#u', $theFile)) {
                        return TRUE;
                }
        }
index 101ac44..29ed282 100644 (file)
@@ -3248,6 +3248,15 @@ class t3lib_divTest extends tx_phpunit_testcase {
        }
 
        /**
+        * Tests whether Unicode characters are recognized as valid file name characters.
+        *
+        * @test
+        */
+       public function validPathStrWorksWithUnicodeFileNames() {
+               $this->assertTrue(t3lib_div::validPathStr('fileadmin/templates/Ссылка (fce).xml'));
+       }
+
+       /**
         * Tests whether verifyFilenameAgainstDenyPattern detects the NULL character.
         *
         * @test