fix(reader): use CSP for protecting foliate instead of iframe sandbox (#848)

This commit is contained in:
James Ward
2026-04-25 18:00:20 -04:00
committed by GitHub
parent 254765f4aa
commit 30434e4dcd
3 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -83,7 +83,7 @@ export class FixedLayout extends HTMLElement {
}) })
// Foliate recommends disabling scripts for untrusted book content: // Foliate recommends disabling scripts for untrusted book content:
// https://github.com/johnfactotum/foliate-js#security // https://github.com/johnfactotum/foliate-js#security
iframe.setAttribute('sandbox', 'allow-same-origin') iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts')
iframe.setAttribute('scrolling', 'no') iframe.setAttribute('scrolling', 'no')
iframe.setAttribute('part', 'filter') iframe.setAttribute('part', 'filter')
this.#root.append(element) this.#root.append(element)
+1 -1
View File
@@ -241,7 +241,7 @@ class View {
}) })
// Foliate recommends disabling scripts for untrusted book content: // Foliate recommends disabling scripts for untrusted book content:
// https://github.com/johnfactotum/foliate-js#security // https://github.com/johnfactotum/foliate-js#security
this.#iframe.setAttribute('sandbox', 'allow-same-origin') this.#iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts')
this.#iframe.setAttribute('scrolling', 'no') this.#iframe.setAttribute('scrolling', 'no')
} }
get element() { get element() {
+1
View File
@@ -6,6 +6,7 @@
<title>Grimmory</title> <title>Grimmory</title>
<base href="/"> <base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover">
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-eval' 'wasm-unsafe-eval'; worker-src blob:; frame-src blob: data:; object-src 'none'; form-action 'none';">
<link rel="icon" type="image/svg+xml" href="assets/favicon.svg"/> <link rel="icon" type="image/svg+xml" href="assets/favicon.svg"/>
<link rel="manifest" href="manifest.webmanifest"> <link rel="manifest" href="manifest.webmanifest">
</head> </head>