[BUGFIX] t3lib_div::unlink_tempfile does not always work on Windows
authorStanislas Rolland <typo3@sjbr.ca>
Wed, 11 Jul 2012 14:42:34 +0000 (10:42 -0400)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 22 Oct 2012 16:07:33 +0000 (18:07 +0200)
Problem: The filename created by t3lib_div::tempnam may contain
backslashes.

Solution: Process the file name through t3lib_div::fixWindowsFilePath

Change-Id: Ie8a23ce82801f6618a8d0ed012121056aa7be0e3
Releases: 4.5, 4.6, 4.7, 6.0
Resolves: #38699
Reviewed-on: http://review.typo3.org/15889
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
t3lib/class.t3lib_div.php

index 78d5f31..89d1b07 100644 (file)
@@ -4126,9 +4126,12 @@ final class t3lib_div {
         * @see upload_to_tempfile(), tempnam()
         */
        public static function unlink_tempfile($uploadedTempFileName) {
-               if ($uploadedTempFileName && self::validPathStr($uploadedTempFileName) && self::isFirstPartOfStr($uploadedTempFileName, PATH_site . 'typo3temp/') && @is_file($uploadedTempFileName)) {
-                       if (unlink($uploadedTempFileName)) {
-                               return TRUE;
+               if ($uploadedTempFileName) {
+                       $uploadedTempFileName = self::fixWindowsFilePath($uploadedTempFileName);
+                       if (self::validPathStr($uploadedTempFileName) && self::isFirstPartOfStr($uploadedTempFileName, PATH_site . 'typo3temp/') && @is_file($uploadedTempFileName)) {
+                               if (unlink($uploadedTempFileName)) {
+                                       return TRUE;
+                               }
                        }
                }
        }