[BUGFIX] Allow frontend requests from different document root 88/34288/3
authorHelmut Hummel <helmut.hummel@typo3.org>
Mon, 17 Nov 2014 10:57:37 +0000 (11:57 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Thu, 4 Dec 2014 01:07:03 +0000 (02:07 +0100)
With a specially prepared index.php and using a page renderer hook
it is in general possible to deliver frontend requests
from a dedicated web folder.

However there are a few (hard coded) issues in TYPO3 which makes
this impossible.

Change GeneralUtility::getIndpEnv('TYPO3_SITE_URL') to check for
a TYPO3_PATH_WEB constant defined in a specially prepared index.php
in a "Web/" folder and provide the fluid stand alone view with
an absolute path (which is meant like that in the API anyways).

This change has no impact on a TYPO3 installation with a traditional
directory structure, but enables users to have a more secure setup
in an appropriate environment.

Resolves: #63025
Releases: 6.2, master
Change-Id: I571ceb6224c8030d1f5f99a45903cda3a8171313
Reviewed-on: http://review.typo3.org/34288
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php

index e7c5219..3a8ef1d 100755 (executable)
@@ -3541,9 +3541,12 @@ Connection: close
                                $retVal = self::getIndpEnv('TYPO3_REQUEST_HOST') . self::dirname(self::getIndpEnv('SCRIPT_NAME')) . '/';
                                break;
                        case 'TYPO3_SITE_URL':
-                               if (defined('PATH_thisScript') && defined('PATH_site')) {
+                               $url = self::getIndpEnv('TYPO3_REQUEST_DIR');
+                               // This can only be set by external entry scripts
+                               if (defined('TYPO3_PATH_WEB')) {
+                                       $retVal = $url;
+                               } elseif (defined('PATH_thisScript') && defined('PATH_site')) {
                                        $lPath = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(dirname(PATH_thisScript)) . '/';
-                                       $url = self::getIndpEnv('TYPO3_REQUEST_DIR');
                                        $siteUrl = substr($url, 0, -strlen($lPath));
                                        if (substr($siteUrl, -1) != '/') {
                                                $siteUrl .= '/';
index eeaf92b..4746a48 100644 (file)
@@ -110,7 +110,7 @@ class FluidTemplateContentObject extends \TYPO3\CMS\Frontend\ContentObject\Abstr
                        /** @var $templateService \TYPO3\CMS\Core\TypoScript\TemplateService */
                        $templateService = $GLOBALS['TSFE']->tmpl;
                        $templatePathAndFilename = $templateService->getFileName($file);
-                       $this->view->setTemplatePathAndFilename($templatePathAndFilename);
+                       $this->view->setTemplatePathAndFilename(PATH_site . $templatePathAndFilename);
                }
        }