[BUGFIX] No CORS Error in WS preview 43/56843/3
authorAlexander Opitz <opitz.alexander@googlemail.com>
Thu, 3 May 2018 10:35:30 +0000 (12:35 +0200)
committerBenni Mack <benni@typo3.org>
Fri, 11 May 2018 04:51:32 +0000 (06:51 +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/56843
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@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/Middleware/WorkspacePreview.php
typo3/sysext/workspaces/Resources/Private/Templates/Preview/Index.html

index f9ecd49..8072db2 100644 (file)
@@ -160,15 +160,11 @@ class PreviewController
         }
         $this->moduleTemplate->getPageRenderer()->addInlineSetting('Workspaces', 'SplitPreviewModes', $splitPreviewModes);
 
-        $backendDomain = $request->getAttribute('normalizedParams')->getRequestHostOnly();
-        $this->getBackendUser()->setAndSaveSessionData('workspaces.backend_domain', $backendDomain);
-
         $this->view->assignMultiple([
             'logoLink' => TYPO3_URL_GENERAL,
             'liveUrl' => $liveUrl ?? false,
             'wsUrl' => $wsUrl,
             'wsSettingsUrl' => $wsSettingsUrl,
-            'backendDomain' => $backendDomain,
             'activeWorkspace' => $availableWorkspaces[$activeWorkspace],
             'splitPreviewModes' => $splitPreviewModes,
             'firstPreviewMode' => current($splitPreviewModes),
index aa91810..58d80c6 100644 (file)
@@ -242,21 +242,12 @@ class ReviewController extends ActionController
         $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, (int)$activeWorkspace, false),
             'activeWorkspaceUid' => $activeWorkspace,
-            'backendDomain' => $backendDomain
         ]);
-        // 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 8999aaa..17a11d0 100644 (file)
@@ -268,13 +268,6 @@ class WorkspacePreview implements MiddlewareInterface
      */
     protected function renderPreviewInfo(TypoScriptFrontendController $tsfe, NormalizedParams $normalizedParams): string
     {
-        $backendDomain = $GLOBALS['BE_USER']->getSessionData('workspaces.backend_domain') ?: $normalizedParams->getRequestHostOnly();
-
-        $content = '<script type="text/javascript">
-       // having this is very important, otherwise the parent.resize call will fail
-       document.domain = ' . GeneralUtility::quoteJSvalue($backendDomain) . ';
-</script>';
-
         if (!isset($tsfe->config['config']['disablePreviewNotification']) || (int)$tsfe->config['config']['disablePreviewNotification'] !== 1) {
             // get the title of the current workspace
             $currentWorkspaceId = $tsfe->whichWorkspace();
index 885dbb8..61fd4b3 100644 (file)
@@ -70,7 +70,4 @@
                </div>
        </div>
 </div>
-<script type="text/javascript">
-       document.domain = '{backendDomain}';
-</script>
 </html>