diff --git a/src/common/reader.js b/src/common/reader.js index 0dc3ce03..0bf75a7d 100644 --- a/src/common/reader.js +++ b/src/common/reader.js @@ -741,6 +741,10 @@ class Reader { this._onSetZoom(iframe, zoom); }); + let onEPUBEncrypted = () => { + this.setErrorMessage(this._getString('pdfReader.epubEncrypted')); + }; + let data; if (this._type === 'pdf') { data = this._data; @@ -812,7 +816,8 @@ class Reader { } else if (this._type === 'epub') { view = new EPUBView({ ...common, - fontFamily: this._state.fontFamily + fontFamily: this._state.fontFamily, + onEPUBEncrypted, }); } else if (this._type === 'snapshot') { view = new SnapshotView({ diff --git a/src/common/stylesheets/components/_other.scss b/src/common/stylesheets/components/_other.scss index 47649d4d..7563e7e3 100644 --- a/src/common/stylesheets/components/_other.scss +++ b/src/common/stylesheets/components/_other.scss @@ -3,21 +3,12 @@ left: 0; right: 0; bottom: 0; - height: 25px; + font-size: rem(16); + height: 2.5em; display: flex; justify-content: center; align-items: center; - background-color: #ff7474; + background-color: var(--accent-red); + color: var(--accent-white); z-index: $z-index-error-bar; } - -#drag-multi { - position: absolute; - top: -3000px; - left: -1000px; - - &::before { - font-size: 30px; - content: '⧉'; - } -} diff --git a/src/common/stylesheets/main.scss b/src/common/stylesheets/main.scss index 4ac7cc5f..0c6d1106 100644 --- a/src/common/stylesheets/main.scss +++ b/src/common/stylesheets/main.scss @@ -37,3 +37,4 @@ @import "components/split-view"; @import "components/outline-view"; @import "components/thumbnails-view"; +@import "components/other"; diff --git a/src/dom/common/dom-view.tsx b/src/dom/common/dom-view.tsx index f02ad3b5..3602c37b 100644 --- a/src/dom/common/dom-view.tsx +++ b/src/dom/common/dom-view.tsx @@ -1212,6 +1212,7 @@ export type DOMViewOptions = { onTabOut: (isShiftTab?: boolean) => void; onKeyUp: (event: KeyboardEvent) => void; onKeyDown: (event: KeyboardEvent) => void; + onEPUBEncrypted: () => void; data: Data & { buf?: Uint8Array, url?: string diff --git a/src/dom/epub/epub-view.ts b/src/dom/epub/epub-view.ts index 8702f8c5..e43c028d 100644 --- a/src/dom/epub/epub-view.ts +++ b/src/dom/epub/epub-view.ts @@ -154,6 +154,12 @@ class EPUBView extends DOMView { let styleScoper = new StyleScoper(this._iframeDocument); await Promise.all(this.book.spine.spineItems.map(section => this._displaySection(section, styleScoper))); + if (this._sectionViews.some(view => view.error) && await this._isEncrypted()) { + this._options.onEPUBEncrypted(); + this._sectionsContainer.remove(); + return; + } + if (this._options.fontFamily) { this._iframeDocument.documentElement.style.setProperty('--content-font-family', this._options.fontFamily); } @@ -195,6 +201,16 @@ class EPUBView extends DOMView { this.book.archive.zip = null; } + private async _isEncrypted() { + try { + let xml = await this.book.archive.request('/META-INF/encryption.xml', 'text') as unknown as string; + return xml.includes('