[BUGFIX] Double protocol when using TCEMAIN.previewDomain 22/41122/2
authorWouter Wolters <typo3@wouterwolters.nl>
Sat, 11 Jul 2015 09:58:48 +0000 (11:58 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 13 Jul 2015 10:33:11 +0000 (12:33 +0200)
In EXT:viewpage the option TCEMAIN.previewDomain is used but
not evaluated correctly. The option can contain the protocol
already and this is not respected in EXT:viewpage.

Check if domain already contains a protocol.

Resolves: #34820
Resolves: #36542
Resolves: #23115
Releases: master, 6.2
Change-Id: I13f7cda1dca54d60d350ba460e43ec924c140d35
Reviewed-on: http://review.typo3.org/41122
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php

index d2c59f8..a681bb7 100644 (file)
@@ -73,15 +73,19 @@ class ViewModuleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionContr
                // Modify relative path to protocol with host if domain record is given
                $protocolAndHost = '..';
                if ($domainName) {
-                       $protocol = 'http';
-                       $page = (array) $sysPage->getPage($finalPageIdToShow);
-                       if ($page['url_scheme'] == 2 || $page['url_scheme'] == 0 && \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
-                               $protocol = 'https';
+                       // TCEMAIN.previewDomain can contain the protocol, check prevents double protocol URLs
+                       if (strpos($domainName, '://') !== FALSE) {
+                               $protocolAndHost = $domainName;
+                       } else {
+                               $protocol = 'http';
+                               $page = (array)$sysPage->getPage($finalPageIdToShow);
+                               if ($page['url_scheme'] == 2 || $page['url_scheme'] == 0 && \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
+                                       $protocol = 'https';
+                               }
+                               $protocolAndHost = $protocol . '://' . $domainName;
                        }
-                       $protocolAndHost = $protocol . '://' . $domainName;
                }
-               $url = $protocolAndHost . '/index.php?id=' . $finalPageIdToShow . $this->getTypeParameterIfSet($finalPageIdToShow) . $mountPointMpParameter . $adminCommand;
-               return $url;
+               return $protocolAndHost . '/index.php?id=' . $finalPageIdToShow . $this->getTypeParameterIfSet($finalPageIdToShow) . $mountPointMpParameter . $adminCommand;
        }
 
        /**