Skip to content

Allow disabling referrer-policy header and disable in startOverlaySession… #14766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion core/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class View implements ViewInterface
private $xFrameOptions = null;
private $enableCacheBuster = true;

private $useStrictReferrerPolicy = true;

/**
* Constructor.
*
Expand Down Expand Up @@ -281,8 +283,11 @@ public function render()
if(!empty($this->xFrameOptions)) {
Common::sendHeader('X-Frame-Options: ' . (string)$this->xFrameOptions);
}

// don't send Referer-Header for outgoing links
Common::sendHeader('Referrer-Policy: same-origin');
if (!empty($this->useStrictReferrerPolicy)) {
Common::sendHeader('Referrer-Policy: same-origin');
}

return $this->renderTwigTemplate();
}
Expand Down Expand Up @@ -460,4 +465,24 @@ private function shouldPropagateTokenAuthInAjaxRequests()
$generalConfig = Config::getInstance()->General;
return Common::getRequestVar('module', false) == 'Widgetize' || $generalConfig['enable_framed_pages'] == '1';
}

/**
* Returns whether a strict Referrer-Policy header will be sent. Generally this should be set to 'true'.
*
* @return bool
*/
public function getUseStrictReferrerPolicy()
{
return $this->useStrictReferrerPolicy;
}

/**
* Sets whether a strict Referrer-Policy header will be sent (if not, nothing is sent).
*
* @param bool $useStrictReferrerPolicy
*/
public function setUseStrictReferrerPolicy($useStrictReferrerPolicy)
{
$this->useStrictReferrerPolicy = $useStrictReferrerPolicy;
}
}
1 change: 1 addition & 0 deletions plugins/Overlay/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public function startOverlaySession()
$view->mainUrl = $site['main_url'];

$this->outputCORSHeaders();
$view->setUseStrictReferrerPolicy(false);
Common::sendHeader('Content-Type: text/html; charset=UTF-8');

return $view->render();
Expand Down