Skip to content

Commit 0d52a9f

Browse files
committed
Merge branch 'release/1.5.2'
2 parents 92617b3 + 08287de commit 0d52a9f

File tree

8 files changed

+20
-14
lines changed

8 files changed

+20
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.5.2 / 2023-02-05
2+
3+
- Исправление проблемы чтения каталога opds для koreader
4+
15
1.5.1 / 2023-01-28
26
------------------
37

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "inpx-web",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"author": "Book Pauk <bookpauk@gmail.com>",
55
"license": "CC0-1.0",
66
"repository": "bookpauk/inpx-web",

server/core/opds/BasePage.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,18 @@ class BasePage {
2424
this.showDeleted = false;
2525
}
2626

27+
escape(s) {
28+
//костыль для koreader, не понимает hex-экранирование вида &#x27;
29+
return he.escape(s).replace(/&#x27;/g, '&#39;').replace(/&#x60;/g, '&#96;');
30+
}
31+
2732
makeEntry(entry = {}) {
2833
if (!entry.id)
2934
throw new Error('makeEntry: no id');
3035
if (!entry.title)
3136
throw new Error('makeEntry: no title');
3237

33-
entry.title = he.escape(entry.title);
38+
entry.title = this.escape(entry.title);
3439

3540
const result = {
3641
updated: (new Date()).toISOString().substring(0, 19) + 'Z',
@@ -48,7 +53,7 @@ class BasePage {
4853
}
4954

5055
makeLink(attrs) {
51-
attrs.href = he.escape(attrs.href);
56+
attrs.href = this.escape(attrs.href);
5257
return {'*ATTRS': attrs};
5358
}
5459

server/core/opds/BookPage.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const path = require('path');
22
const _ = require('lodash');
3-
const he = require('he');
43
const dayjs = require('dayjs');
54

65
const BasePage = require('./BasePage');
@@ -190,7 +189,7 @@ class BookPage extends BasePage {
190189
if (content) {
191190
e.content = {
192191
'*ATTRS': {type: 'text/html'},
193-
'*TEXT': he.escape(content),
192+
'*TEXT': this.escape(content),
194193
};
195194
}
196195

server/core/opds/GenrePage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class GenrePage extends BasePage {
1414

1515
const query = {
1616
from: req.query.from || 'search',
17-
term: req.query.term || '*',
17+
term: req.query.term || '',
1818
section: req.query.section || '',
1919
};
2020

server/core/opds/SearchHelpPage.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const he = require('he');
2-
31
const BasePage = require('./BasePage');
42

53
class SearchHelpPage extends BasePage {
@@ -45,7 +43,7 @@ class SearchHelpPage extends BasePage {
4543
title: this.title,
4644
content: {
4745
'*ATTRS': {type: 'text/html'},
48-
'*TEXT': he.escape(content),
46+
'*TEXT': this.escape(content),
4947
},
5048
link: [
5149
this.downLink({href: '/book/fake-link', type: `application/fb2+zip`})

server/core/opds/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const OpensearchPage = require('./OpensearchPage');
1111
const SearchPage = require('./SearchPage');
1212
const SearchHelpPage = require('./SearchHelpPage');
1313

14+
const log = new (require('../AppLogger'))().log;//singleton
15+
1416
module.exports = function(app, config) {
1517
if (!config.opds || !config.opds.enabled)
1618
return;
@@ -63,10 +65,8 @@ module.exports = function(app, config) {
6365
next();
6466
}
6567
} catch (e) {
68+
log(LM_ERR, `OPDS: ${e.message}, url: ${req.originalUrl}`);
6669
res.status(500).send({error: e.message});
67-
if (config.branch == 'development') {
68-
console.error({error: e.message, url: req.originalUrl});
69-
}
7070
}
7171
};
7272

0 commit comments

Comments
 (0)