diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2020-03-22 14:23:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-22 14:23:17 +0100 |
commit | 019ba27943a44a5c3b80ffac02c5568ee47af6cc (patch) | |
tree | 2b81be48519f088d4601ba3b79cbf4fe77821e1f /apps/dav/lib | |
parent | 47fafead819d6c1749d962c255ad83efdd251303 (diff) | |
parent | 82f8a167a67e49b4128428251c0960ffd7e9f63e (diff) | |
download | nextcloud-server-019ba27943a44a5c3b80ffac02c5568ee47af6cc.tar.gz nextcloud-server-019ba27943a44a5c3b80ffac02c5568ee47af6cc.zip |
Merge pull request #20042 from nextcloud/fix/noid/styled-dav-browser-error
fix dav browser error page not styled
Diffstat (limited to 'apps/dav/lib')
-rw-r--r-- | apps/dav/lib/Files/BrowserErrorPagePlugin.php | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/apps/dav/lib/Files/BrowserErrorPagePlugin.php b/apps/dav/lib/Files/BrowserErrorPagePlugin.php index e1e64b3e6f4..9bc169601af 100644 --- a/apps/dav/lib/Files/BrowserErrorPagePlugin.php +++ b/apps/dav/lib/Files/BrowserErrorPagePlugin.php @@ -25,6 +25,7 @@ namespace OCA\DAV\Files; use OC\AppFramework\Http\Request; use OC_Template; +use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\IRequest; use Sabre\DAV\Exception; use Sabre\DAV\Server; @@ -80,8 +81,10 @@ class BrowserErrorPagePlugin extends ServerPlugin { } $this->server->httpResponse->addHeaders($headers); $this->server->httpResponse->setStatus($httpCode); - $body = $this->generateBody(); + $body = $this->generateBody($httpCode); $this->server->httpResponse->setBody($body); + $csp = new ContentSecurityPolicy(); + $this->server->httpResponse->addHeader('Content-Security-Policy', $csp->buildPolicy()); $this->sendResponse(); } @@ -89,9 +92,15 @@ class BrowserErrorPagePlugin extends ServerPlugin { * @codeCoverageIgnore * @return bool|string */ - public function generateBody() { + public function generateBody(int $httpCode) { $request = \OC::$server->getRequest(); - $content = new OC_Template('dav', 'exception', 'guest'); + + $templateName = 'exception'; + if($httpCode === 403 || $httpCode === 404) { + $templateName = (string)$httpCode; + } + + $content = new OC_Template('core', $templateName, 'guest'); $content->assign('title', $this->server->httpResponse->getStatusText()); $content->assign('remoteAddr', $request->getRemoteAddress()); $content->assign('requestID', $request->getId()); |