Skip to content
Merged
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
18 changes: 8 additions & 10 deletions lib/public/AppFramework/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,9 @@ class Response {
private $throttleMetadata = [];

/**
* Response constructor.
*
* @since 17.0.0
*/
public function __construct() {
$this->setContentSecurityPolicy(new EmptyContentSecurityPolicy());
$this->setFeaturePolicy(new EmptyFeaturePolicy());
}

/**
Expand Down Expand Up @@ -241,12 +237,8 @@ public function getHeaders() {
$this->lastModified->format(\DateTime::RFC2822);
}

// Build Content-Security-Policy and use default if none has been specified
if(is_null($this->contentSecurityPolicy)) {
$this->setContentSecurityPolicy(new ContentSecurityPolicy());
}
$this->headers['Content-Security-Policy'] = $this->contentSecurityPolicy->buildPolicy();
$this->headers['Feature-Policy'] = $this->featurePolicy->buildPolicy();
$this->headers['Content-Security-Policy'] = $this->getContentSecurityPolicy()->buildPolicy();
$this->headers['Feature-Policy'] = $this->getFeaturePolicy()->buildPolicy();

if($this->ETag) {
$mergeWith['ETag'] = '"' . $this->ETag . '"';
Expand Down Expand Up @@ -296,6 +288,9 @@ public function setContentSecurityPolicy(EmptyContentSecurityPolicy $csp) {
* @since 8.1.0
*/
public function getContentSecurityPolicy() {
if ($this->contentSecurityPolicy === null) {
$this->setContentSecurityPolicy(new EmptyContentSecurityPolicy());
}
return $this->contentSecurityPolicy;
}

Expand All @@ -304,6 +299,9 @@ public function getContentSecurityPolicy() {
* @since 17.0.0
*/
public function getFeaturePolicy(): EmptyFeaturePolicy {
if ($this->featurePolicy === null) {
$this->setFeaturePolicy(new EmptyFeaturePolicy());
}
return $this->featurePolicy;
}

Expand Down