[BUGFIX] .htaccess created for log folder outside PATH_site 36/41736/4
authorAndreas Wolf <andreas.wolf@typo3.org>
Sun, 19 Jul 2015 11:29:55 +0000 (13:29 +0200)
committerSteffen Müller <typo3@t3node.com>
Fri, 13 Nov 2015 23:16:41 +0000 (00:16 +0100)
Change-Id: I47d38033581a3ac71ee61d9607c708c01fe56743
Resolves: #68368
Releases: master, 6.2
Reviewed-on: https://review.typo3.org/41736
Reviewed-by: Oliver Eglseder <oliver.eglseder@in2code.de>
Tested-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Reviewed-by: Steffen Müller <typo3@t3node.com>
Tested-by: Steffen Müller <typo3@t3node.com>
typo3/sysext/core/Classes/Log/Writer/FileWriter.php
typo3/sysext/core/Tests/Unit/Log/Writer/FileWriterTest.php

index 971373b..891bb2c 100644 (file)
@@ -191,8 +191,11 @@ class FileWriter extends AbstractWriter
         $logFileDirectory = dirname($this->logFile);
         if (!@is_dir($logFileDirectory)) {
             GeneralUtility::mkdir_deep($logFileDirectory);
-            // only create .htaccess, if we created the directory on our own
-            $this->createHtaccessFile($logFileDirectory . '/.htaccess');
+            // create .htaccess file if log file is within the site path
+            if (PathUtility::getCommonPrefix(array(PATH_site, $logFileDirectory)) === PATH_site) {
+                // only create .htaccess, if we created the directory on our own
+                $this->createHtaccessFile($logFileDirectory . '/.htaccess');
+            }
         }
         // create the log file
         GeneralUtility::writeFile($this->logFile, '');
index 654a3c5..f6bd074 100644 (file)
@@ -186,31 +186,4 @@ class FileWriterTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         $firstWriter->setLogFile($this->getDefaultFileName($logFilePrefix));
         $secondWriter->setLogFile($this->getDefaultFileName($logFilePrefix));
     }
-
-    /**
-     * @test
-     */
-    public function createsHtaccessForNewDirectory()
-    {
-        $this->setUpVfsStream();
-        $directory = $this->getUniqueId('Log');
-        $logFile = 'vfs://LogRoot/' . $directory . '/' . $this->logFileName;
-        $this->createWriter()->setLogFile($logFile);
-        $this->assertFileExists('vfs://LogRoot/' . $directory . '/.htaccess');
-    }
-
-    /**
-     * @test
-     */
-    public function createsNoHtaccessForExistingDirectory()
-    {
-        $this->setUpVfsStream();
-        $directory = $this->getUniqueId('Log');
-            // create a directory
-        vfsStreamWrapper::getRoot()->addChild(new vfsStreamDirectory($directory));
-        $logFile = 'vfs://LogRoot/' . $directory . '/' . $this->logFileName;
-        $this->assertTrue(is_dir('vfs://LogRoot/' . $directory));
-        $this->createWriter()->setLogFile($logFile);
-        $this->assertFileNotExists('vfs://LogRoot/' . $directory . '/.htaccess');
-    }
 }