From ab97a9d6137470bf254353b5ced8b7a457c63637 Mon Sep 17 00:00:00 2001 From: advplyr Date: Tue, 12 Sep 2023 10:41:39 -0500 Subject: [PATCH] Fix:Crash when updating book author or series that includes an apostrophe #2070 --- server/models/Author.js | 7 +++++-- server/models/Series.js | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/server/models/Author.js b/server/models/Author.js index 790b35dd..220abeb8 100644 --- a/server/models/Author.js +++ b/server/models/Author.js @@ -114,11 +114,14 @@ class Author extends Model { static async getOldByNameAndLibrary(authorName, libraryId) { const author = (await this.findOne({ where: [ - literal(`name = '${authorName}' COLLATE NOCASE`), + literal(`name = ':authorName' COLLATE NOCASE`), { libraryId } - ] + ], + replacements: { + authorName + } }))?.getOldAuthor() return author } diff --git a/server/models/Series.js b/server/models/Series.js index e8407d5c..2b37002d 100644 --- a/server/models/Series.js +++ b/server/models/Series.js @@ -105,11 +105,14 @@ class Series extends Model { static async getOldByNameAndLibrary(seriesName, libraryId) { const series = (await this.findOne({ where: [ - literal(`name = '${seriesName}' COLLATE NOCASE`), + literal(`name = ':seriesName' COLLATE NOCASE`), { libraryId } - ] + ], + replacements: { + seriesName + } }))?.getOldSeries() return series }