Skip to content

Commit

Permalink
Merge branch 'release/1.5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
bookpauk committed Feb 5, 2023
2 parents 92617b3 + 08287de commit 0d52a9f
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.5.2 / 2023-02-05

- Исправление проблемы чтения каталога opds для koreader

1.5.1 / 2023-01-28
------------------

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "inpx-web",
"version": "1.5.1",
"version": "1.5.2",
"author": "Book Pauk <bookpauk@gmail.com>",
"license": "CC0-1.0",
"repository": "bookpauk/inpx-web",
Expand Down
9 changes: 7 additions & 2 deletions server/core/opds/BasePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@ class BasePage {
this.showDeleted = false;
}

escape(s) {
//костыль для koreader, не понимает hex-экранирование вида &#x27;
return he.escape(s).replace(/&#x27;/g, '&#39;').replace(/&#x60;/g, '&#96;');
}

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',
Expand All @@ -48,7 +53,7 @@ class BasePage {
}

makeLink(attrs) {
attrs.href = he.escape(attrs.href);
attrs.href = this.escape(attrs.href);
return {'*ATTRS': attrs};
}

Expand Down
3 changes: 1 addition & 2 deletions server/core/opds/BookPage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const path = require('path');
const _ = require('lodash');
const he = require('he');
const dayjs = require('dayjs');

const BasePage = require('./BasePage');
Expand Down Expand Up @@ -190,7 +189,7 @@ class BookPage extends BasePage {
if (content) {
e.content = {
'*ATTRS': {type: 'text/html'},
'*TEXT': he.escape(content),
'*TEXT': this.escape(content),
};
}

Expand Down
2 changes: 1 addition & 1 deletion server/core/opds/GenrePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GenrePage extends BasePage {

const query = {
from: req.query.from || 'search',
term: req.query.term || '*',
term: req.query.term || '',
section: req.query.section || '',
};

Expand Down
4 changes: 1 addition & 3 deletions server/core/opds/SearchHelpPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const he = require('he');

const BasePage = require('./BasePage');

class SearchHelpPage extends BasePage {
Expand Down Expand Up @@ -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`})
Expand Down
6 changes: 3 additions & 3 deletions server/core/opds/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const OpensearchPage = require('./OpensearchPage');
const SearchPage = require('./SearchPage');
const SearchHelpPage = require('./SearchHelpPage');

const log = new (require('../AppLogger'))().log;//singleton

module.exports = function(app, config) {
if (!config.opds || !config.opds.enabled)
return;
Expand Down Expand Up @@ -63,10 +65,8 @@ module.exports = function(app, config) {
next();
}
} catch (e) {
log(LM_ERR, `OPDS: ${e.message}, url: ${req.originalUrl}`);
res.status(500).send({error: e.message});
if (config.branch == 'development') {
console.error({error: e.message, url: req.originalUrl});
}
}
};

Expand Down

0 comments on commit 0d52a9f

Please sign in to comment.