Skip to content

Commit

Permalink
Merge pull request #924 from kiwix/pdf-friendly-kiwix-serve
Browse files Browse the repository at this point in the history
  • Loading branch information
mgautierfr authored Apr 5, 2023
2 parents e13fed8 + a6659cb commit 453f02c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/server/response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,12 @@ ContentResponse::ContentResponse(const std::string& root, bool verbose, const st
m_mimeType(mimetype)
{
add_header(MHD_HTTP_HEADER_CONTENT_TYPE, m_mimeType);
if ( !startsWith(m_mimeType, "application/pdf") ) {
add_header("Content-Security-Policy",
"default-src 'self' data: blob: about: chrome-extension: 'unsafe-inline' 'unsafe-eval'; "
"sandbox allow-scripts allow-same-origin allow-modals allow-popups allow-forms allow-downloads;");
add_header("Referrer-Policy", "no-referrer");
}
}

std::unique_ptr<ContentResponse> ContentResponse::build(
Expand Down
7 changes: 5 additions & 2 deletions static/viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy"
content="default-src 'self' data: 'unsafe-inline' 'unsafe-eval';
frame-src 'self' moz-extension: chrome-extension:;
object-src 'none';">
<title>ZIM Viewer</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link type="text/css" href="./skin/taskbar.css?KIWIXCACHEID" rel="Stylesheet" />
Expand Down Expand Up @@ -65,8 +69,7 @@
</div>

<iframe id="content_iframe"
referrerpolicy="same-origin"
sandbox="allow-same-origin allow-scripts"
referrerpolicy="no-referrer"
onload="on_content_load()"
src="./skin/blank.html?KIWIXCACHEID" title="ZIM content" width="100%"
style="border:0px">
Expand Down

0 comments on commit 453f02c

Please sign in to comment.