[BUGFIX] No CORS Error in WS preview 18/56918/2
authorBenni Mack <benni@typo3.org>
Fri, 11 May 2018 04:56:13 +0000 (06:56 +0200)
committerBenni Mack <benni@typo3.org>
Fri, 11 May 2018 05:15:32 +0000 (07:15 +0200)
We should not manipulate document.domain in workspace preview as we need
to communicate with our parent master window.

Releases: master, 8.7
Resolves: #78401
Change-Id: Id3f581545a5547ca4ab8c46ee204b1c947ff6e56
Reviewed-on: https://review.typo3.org/56918
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/workspaces/Classes/Controller/PreviewController.php
typo3/sysext/workspaces/Classes/Controller/ReviewController.php
typo3/sysext/workspaces/Classes/Hook/TypoScriptFrontendControllerHook.php
typo3/sysext/workspaces/Resources/Private/Layouts/Popup.html [deleted file]
typo3/sysext/workspaces/Resources/Private/Templates/Preview/Index.html
typo3/sysext/workspaces/Resources/Private/Templates/Preview/Preview.html [deleted file]

index da62bcc..637a1c6 100644 (file)
@@ -126,7 +126,6 @@ class PreviewController extends AbstractController
             $liveUrl = $wsBaseUrl . '&ADMCMD_noBeUser=1&ADMCMD_prev=IGNORE';
         }
         $wsUrl = $wsBaseUrl . '&ADMCMD_prev=IGNORE&ADMCMD_view=1&ADMCMD_editIcons=1&ADMCMD_previewWS=' . $backendUser->workspace;
-        $backendDomain = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY');
         $splitPreviewTsConfig = BackendUtility::getModTSconfig($this->pageId, 'workspaces.splitPreviewModes');
         $splitPreviewModes = GeneralUtility::trimExplode(',', $splitPreviewTsConfig['value']);
         $allPreviewModes = ['slider', 'vbox', 'hbox'];
@@ -144,8 +143,6 @@ class PreviewController extends AbstractController
         $cssFile = GeneralUtility::getFileAbsFileName($cssFile);
         $this->pageRenderer->addCssFile(PathUtility::getAbsoluteWebPath($cssFile));
 
-        $backendUser->setAndSaveSessionData('workspaces.backend_domain', GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'));
-
         $logoPath = GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Public/Images/typo3_logo_orange.svg');
         $logoWidth = 22;
         $logoHeight = 22;
@@ -158,7 +155,6 @@ class PreviewController extends AbstractController
             'liveUrl' => $liveUrl,
             'wsUrl' => $wsUrl,
             'wsSettingsUrl' => $wsSettingsUrl,
-            'backendDomain' => $backendDomain,
             'activeWorkspace' => $wsList[$activeWorkspace],
             'splitPreviewModes' => $splitPreviewModes,
             'firstPreviewMode' => current($splitPreviewModes),
index 2ffb5dd..22c4d1c 100644 (file)
@@ -168,21 +168,12 @@ class ReviewController extends AbstractController
         $activeWorkspace = $this->getBackendUser()->workspace;
         $wsCur = [$activeWorkspace => true];
         $wsList = array_intersect_key($wsList, $wsCur);
-        $backendDomain = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY');
         $this->view->assignMultiple([
             'pageUid' => (int)GeneralUtility::_GP('id'),
             'showGrid' => true,
             'workspaceList' => $this->prepareWorkspaceTabs($wsList, $activeWorkspace, false),
-            'activeWorkspaceUid' => $activeWorkspace,
-            'backendDomain' => $backendDomain
+            'activeWorkspaceUid' => $activeWorkspace
         ]);
-        // Setting the document.domain early before JavScript
-        // libraries are loaded, try to access top frame reference
-        // and possibly run into some CORS issue
-        $this->pageRenderer->setMetaCharsetTag(
-            $this->pageRenderer->getMetaCharsetTag() . LF
-            . GeneralUtility::wrapJS('document.domain = ' . GeneralUtility::quoteJSvalue($backendDomain) . ';')
-        );
         $this->pageRenderer->addInlineSetting('Workspaces', 'singleView', '1');
     }
 
index 5984f1a..ddc89b5 100644 (file)
@@ -45,19 +45,7 @@ class TypoScriptFrontendControllerHook
             return '';
         }
 
-        if (empty($this->getBackendUserAuthentication()->getSessionData('workspaces.backend_domain'))) {
-            $backendDomain = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY');
-        } else {
-            $backendDomain = $this->getBackendUserAuthentication()->getSessionData('workspaces.backend_domain');
-        }
-
-        $content = $pObj->cObj->cObjGetSingle('FLUIDTEMPLATE', [
-            'file' => 'EXT:workspaces/Resources/Private/Templates/Preview/Preview.html',
-            'variables.' => [
-                'backendDomain' => 'TEXT',
-                'backendDomain.' => ['value' => $backendDomain]
-            ]
-        ]);
+        $content = '';
 
         if (!isset($pObj->config['config']['disablePreviewNotification']) || (int)$pObj->config['config']['disablePreviewNotification'] !== 1) {
             // get the title of the current workspace
diff --git a/typo3/sysext/workspaces/Resources/Private/Layouts/Popup.html b/typo3/sysext/workspaces/Resources/Private/Layouts/Popup.html
deleted file mode 100644 (file)
index 8b997bb..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<f:render section="main" />
-<script type="text/javascript">
-       document.domain = '{backendDomain}';
-</script>
index bdfcd6c..dcd18e3 100644 (file)
@@ -1,5 +1,5 @@
 <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
-<f:layout name="popup" />
+<f:layout name="Empty" />
 
 <f:section name="main">
        <div id="typo3-topbar">
@@ -64,4 +64,4 @@
 
        </div>
 </f:section>
-</html>
\ No newline at end of file
+</html>
diff --git a/typo3/sysext/workspaces/Resources/Private/Templates/Preview/Preview.html b/typo3/sysext/workspaces/Resources/Private/Templates/Preview/Preview.html
deleted file mode 100644 (file)
index 0c16f8d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<script type="text/javascript">
-       // having this is very important, otherwise the parent.resize call will fail
-       document.domain = '{backendDomain}';
-</script>
\ No newline at end of file