Skip to content

Commit cf25e6f

Browse files
committed
Merge pull request #14773 from owncloud/allow-iframes-from-self-in-share-view
Allow iframes from same domain in share view
2 parents dbade19 + 48243a2 commit cf25e6f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

apps/files_sharing/lib/controllers/sharecontroller.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,12 @@ public function showShare($token, $path = '') {
203203
$shareTmpl['downloadURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', array('token' => $token));
204204
$shareTmpl['maxSizeAnimateGif'] = $this->config->getSystemValue('max_filesize_animated_gifs_public_sharing', 10);
205205

206-
return new TemplateResponse($this->appName, 'public', $shareTmpl, 'base');
206+
$csp = new OCP\AppFramework\Http\ContentSecurityPolicy();
207+
$csp->addAllowedFrameDomain('\'self\'');
208+
$response = new TemplateResponse($this->appName, 'public', $shareTmpl, 'base');
209+
$response->setContentSecurityPolicy($csp);
210+
211+
return $response;
207212
}
208213

209214
/**

apps/files_sharing/tests/controller/sharecontroller.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,12 @@ public function testShowShare() {
159159
'nonHumanFileSize' => 33,
160160
'maxSizeAnimateGif' => 10,
161161
);
162+
163+
$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
164+
$csp->addAllowedFrameDomain('\'self\'');
162165
$expectedResponse = new TemplateResponse($this->container['AppName'], 'public', $sharedTmplParams, 'base');
166+
$expectedResponse->setContentSecurityPolicy($csp);
167+
163168
$this->assertEquals($expectedResponse, $response);
164169
}
165170

0 commit comments

Comments
 (0)