fix(reader): remove foliate allow-scripts and add CSP for EPUB resources
This commit is contained in:
@@ -68,7 +68,9 @@ public class EpubReaderController {
|
|||||||
"application/vnd.ms-fontobject".equals(contentType)) {
|
"application/vnd.ms-fontobject".equals(contentType)) {
|
||||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||||
}
|
}
|
||||||
|
// Defense in depth for untrusted EPUB resources. See Foliate's security guidance:
|
||||||
|
// https://github.com/johnfactotum/foliate-js#security
|
||||||
|
response.setHeader("Content-Security-Policy", "script-src 'none'");
|
||||||
response.setHeader("Cache-Control", "public, max-age=3600");
|
response.setHeader("Cache-Control", "public, max-age=3600");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -81,9 +81,9 @@ export class FixedLayout extends HTMLElement {
|
|||||||
display: 'none',
|
display: 'none',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
})
|
})
|
||||||
// `allow-scripts` is needed for events because of WebKit bug
|
// Foliate recommends disabling scripts for untrusted book content:
|
||||||
// https://bugs.webkit.org/show_bug.cgi?id=218086
|
// https://github.com/johnfactotum/foliate-js#security
|
||||||
iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts')
|
iframe.setAttribute('sandbox', 'allow-same-origin')
|
||||||
iframe.setAttribute('scrolling', 'no')
|
iframe.setAttribute('scrolling', 'no')
|
||||||
iframe.setAttribute('part', 'filter')
|
iframe.setAttribute('part', 'filter')
|
||||||
this.#root.append(element)
|
this.#root.append(element)
|
||||||
|
|||||||
@@ -239,9 +239,9 @@ class View {
|
|||||||
display: 'none',
|
display: 'none',
|
||||||
width: '100%', height: '100%',
|
width: '100%', height: '100%',
|
||||||
})
|
})
|
||||||
// `allow-scripts` is needed for events because of WebKit bug
|
// Foliate recommends disabling scripts for untrusted book content:
|
||||||
// https://bugs.webkit.org/show_bug.cgi?id=218086
|
// https://github.com/johnfactotum/foliate-js#security
|
||||||
this.#iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts')
|
this.#iframe.setAttribute('sandbox', 'allow-same-origin')
|
||||||
this.#iframe.setAttribute('scrolling', 'no')
|
this.#iframe.setAttribute('scrolling', 'no')
|
||||||
}
|
}
|
||||||
get element() {
|
get element() {
|
||||||
|
|||||||
Reference in New Issue
Block a user