[BUGFIX] .htaccess created for log folder outside PATH_site 15/44715/2
authorAndreas Wolf <andreas.wolf@typo3.org>
Sun, 19 Jul 2015 11:29:55 +0000 (13:29 +0200)
committerSteffen Müller <typo3@t3node.com>
Sat, 14 Nov 2015 19:33:50 +0000 (20:33 +0100)
Change-Id: I47d38033581a3ac71ee61d9607c708c01fe56743
Resolves: #68368
Releases: master, 6.2
Reviewed-on: https://review.typo3.org/44715
Reviewed-by: Bjoern Jacob <bjoern.jacob@tritum.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 e0ca278..04773dd 100644 (file)
@@ -186,8 +186,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 118c85e..72f6993 100644 (file)
@@ -177,30 +177,4 @@ class FileWriterTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $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');
-       }
-
 }