From 9126973378fcf1ecad3ce56e7dbd5401e87239f6 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 5 Feb 2023 17:35:24 +0700 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B1=D0=BB=D0=B5?= =?UTF-8?q?=D0=BC=D1=8B=20=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BA?= =?UTF-8?q?=D0=B0=D1=82=D0=B0=D0=BB=D0=BE=D0=B3=D0=B0=20opds=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20koreader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/opds/BasePage.js | 9 +++++++-- server/core/opds/BookPage.js | 3 +-- server/core/opds/SearchHelpPage.js | 4 +--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/server/core/opds/BasePage.js b/server/core/opds/BasePage.js index c986f1f..38eeb9a 100644 --- a/server/core/opds/BasePage.js +++ b/server/core/opds/BasePage.js @@ -24,13 +24,18 @@ class BasePage { this.showDeleted = false; } + escape(s) { + //костыль для koreader, не понимает hex-экранирование вида ' + return he.escape(s).replace(/'/g, ''').replace(/`/g, '`'); + } + makeEntry(entry = {}) { if (!entry.id) throw new Error('makeEntry: no id'); if (!entry.title) throw new Error('makeEntry: no title'); - entry.title = he.escape(entry.title); + entry.title = this.escape(entry.title); const result = { updated: (new Date()).toISOString().substring(0, 19) + 'Z', @@ -48,7 +53,7 @@ class BasePage { } makeLink(attrs) { - attrs.href = he.escape(attrs.href); + attrs.href = this.escape(attrs.href); return {'*ATTRS': attrs}; } diff --git a/server/core/opds/BookPage.js b/server/core/opds/BookPage.js index d46fef3..da04dcb 100644 --- a/server/core/opds/BookPage.js +++ b/server/core/opds/BookPage.js @@ -1,6 +1,5 @@ const path = require('path'); const _ = require('lodash'); -const he = require('he'); const dayjs = require('dayjs'); const BasePage = require('./BasePage'); @@ -190,7 +189,7 @@ class BookPage extends BasePage { if (content) { e.content = { '*ATTRS': {type: 'text/html'}, - '*TEXT': he.escape(content), + '*TEXT': this.escape(content), }; } diff --git a/server/core/opds/SearchHelpPage.js b/server/core/opds/SearchHelpPage.js index 60c084a..246f499 100644 --- a/server/core/opds/SearchHelpPage.js +++ b/server/core/opds/SearchHelpPage.js @@ -1,5 +1,3 @@ -const he = require('he'); - const BasePage = require('./BasePage'); class SearchHelpPage extends BasePage { @@ -45,7 +43,7 @@ class SearchHelpPage extends BasePage { title: this.title, content: { '*ATTRS': {type: 'text/html'}, - '*TEXT': he.escape(content), + '*TEXT': this.escape(content), }, link: [ this.downLink({href: '/book/fake-link', type: `application/fb2+zip`})