Merge pull request #924 from kiwix/pdf-friendly-kiwix-serve

This commit is contained in:
Matthieu Gautier 2023-04-05 15:41:37 +02:00 committed by GitHub
commit 453f02cc85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -412,6 +412,12 @@ ContentResponse::ContentResponse(const std::string& root, bool verbose, const st
m_mimeType(mimetype) m_mimeType(mimetype)
{ {
add_header(MHD_HTTP_HEADER_CONTENT_TYPE, m_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( std::unique_ptr<ContentResponse> ContentResponse::build(

View File

@ -2,6 +2,10 @@
<html> <html>
<head> <head>
<meta charset="UTF-8"> <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> <title>ZIM Viewer</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link type="text/css" href="./skin/taskbar.css?KIWIXCACHEID" rel="Stylesheet" /> <link type="text/css" href="./skin/taskbar.css?KIWIXCACHEID" rel="Stylesheet" />
@ -65,8 +69,7 @@
</div> </div>
<iframe id="content_iframe" <iframe id="content_iframe"
referrerpolicy="same-origin" referrerpolicy="no-referrer"
sandbox="allow-same-origin allow-scripts"
onload="on_content_load()" onload="on_content_load()"
src="./skin/blank.html?KIWIXCACHEID" title="ZIM content" width="100%" src="./skin/blank.html?KIWIXCACHEID" title="ZIM content" width="100%"
style="border:0px"> style="border:0px">