[BUGFIX] Ignore open_basedir warning for files outside the website root 14/52614/4
authorChristian Toffolo <ian@webian.it>
Wed, 26 Apr 2017 14:33:39 +0000 (16:33 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Wed, 3 May 2017 11:20:26 +0000 (13:20 +0200)
Suppress warnings generated by getFilenameFromMainDir() when it needs
to check file paths outside the website root and open_basedir
is in effect.

Resolves: #81024
Releases: master, 8.7
Change-Id: Ia339c907577547374545c0a94393f698828523c7
Reviewed-on: https://review.typo3.org/52614
Reviewed-by: Stephan Großberndt <stephan@grossberndt.de>
Tested-by: Stephan Großberndt <stephan@grossberndt.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Henrik Elsner <helsner@dfau.de>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/core/Classes/Resource/ResourceCompressor.php

index 0bd2dfe..3f62388 100644 (file)
@@ -437,7 +437,8 @@ class ResourceCompressor
 
         // if the file is an absolute reference within the docRoot
         $absolutePath = $docRoot . '/' . $fileNameWithoutSlash;
-        if (is_file($absolutePath)) {
+        // Calling is_file without @ for a path starting with '../' causes a PHP Warning when using open_basedir restriction
+        if (@is_file($absolutePath)) {
             if (strpos($absolutePath, $this->rootPath) === 0) {
                 // the path is within the current root path, simply strip rootPath off
                 return substr($absolutePath, strlen($this->rootPath));