summaryrefslogtreecommitdiffstats
path: root/lib/public/appframework
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-03-10 10:30:44 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-03-10 10:30:44 +0100
commit214fa44400be2b3f68566f54feff389f20f3a445 (patch)
treea5338a6c00807f036ef2deeef9bc0c167c2d46f0 /lib/public/appframework
parente069d9d3f913c867085d5969843c8c12786b1133 (diff)
parentb29940d956e638b14f2012022b0ad91ebac7f8e8 (diff)
downloadnextcloud-server-214fa44400be2b3f68566f54feff389f20f3a445.tar.gz
nextcloud-server-214fa44400be2b3f68566f54feff389f20f3a445.zip
Merge pull request #14534 from owncloud/add-child-src
Add support for 'child-src' directive
Diffstat (limited to 'lib/public/appframework')
-rw-r--r--lib/public/appframework/http/contentsecuritypolicy.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/public/appframework/http/contentsecuritypolicy.php b/lib/public/appframework/http/contentsecuritypolicy.php
index cb9a241d8af..6778d1035be 100644
--- a/lib/public/appframework/http/contentsecuritypolicy.php
+++ b/lib/public/appframework/http/contentsecuritypolicy.php
@@ -65,6 +65,8 @@ class ContentSecurityPolicy {
private $allowedFontDomains = [
'\'self\'',
];
+ /** @var array Domains from which web-workers and nested browsing content can load elements */
+ private $allowedChildSrcDomains = [];
/**
* Whether inline JavaScript snippets are allowed or forbidden
@@ -181,6 +183,16 @@ class ContentSecurityPolicy {
}
/**
+ * Domains from which web-workers and nested browsing content can load elements
+ * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized.
+ * @return $this
+ */
+ public function addAllowedChildSrcDomain($domain) {
+ $this->allowedChildSrcDomains[] = $domain;
+ return $this;
+ }
+
+ /**
* Get the generated Content-Security-Policy as a string
* @return string
*/
@@ -236,6 +248,11 @@ class ContentSecurityPolicy {
$policy .= ';';
}
+ if(!empty($this->allowedChildSrcDomains)) {
+ $policy .= 'child-src ' . implode(' ', $this->allowedChildSrcDomains);
+ $policy .= ';';
+ }
+
return rtrim($policy, ';');
}
}