From dc711e671d2fe10f13d476cb841d143e8b5d7a58 Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Thu, 22 May 2025 18:04:40 -0700 Subject: [PATCH] unescape ampersand (&) (#923) --- kindlecomicconverter/comic2ebook.py | 10 +++++----- kindlecomicconverter/metadata.py | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index ce091b9..4a2dcc2 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -285,9 +285,9 @@ def buildOPF(dstdir, title, filelist, cover=None): "urn:uuid:", options.uuid, "\n", "KindleComicConverter-" + __version__ + "\n"]) if len(options.summary) > 0: - f.writelines(["", options.summary, "\n"]) + f.writelines(["", hescape(options.summary), "\n"]) for author in options.authors: - f.writelines(["", author, "\n"]) + f.writelines(["", hescape(author), "\n"]) f.writelines(["" + strftime("%Y-%m-%dT%H:%M:%SZ", gmtime()) + "\n", "\n"]) if options.iskindle and options.profile != 'Custom': @@ -743,7 +743,7 @@ def getComicInfo(path, originalpath): return if defaultTitle: if xml.data['Series']: - options.title = hescape(xml.data['Series']) + options.title = xml.data['Series'] if xml.data['Volume']: titleSuffix += ' V' + xml.data['Volume'].zfill(2) if xml.data['Number']: @@ -753,7 +753,7 @@ def getComicInfo(path, originalpath): options.authors = [] for field in ['Writers', 'Pencillers', 'Inkers', 'Colorists']: for person in xml.data[field]: - options.authors.append(hescape(person)) + options.authors.append(person) if len(options.authors) > 0: options.authors = list(set(options.authors)) options.authors.sort() @@ -762,7 +762,7 @@ def getComicInfo(path, originalpath): if xml.data['Bookmarks']: options.comicinfo_chapters = xml.data['Bookmarks'] if xml.data['Summary']: - options.summary = hescape(xml.data['Summary']) + options.summary = xml.data['Summary'] os.remove(xmlPath) diff --git a/kindlecomicconverter/metadata.py b/kindlecomicconverter/metadata.py index 51ade3b..e0d075a 100644 --- a/kindlecomicconverter/metadata.py +++ b/kindlecomicconverter/metadata.py @@ -20,6 +20,7 @@ import os from xml.dom.minidom import parse, Document from tempfile import mkdtemp from shutil import rmtree +from xml.sax.saxutils import unescape from . import comicarchive @@ -52,19 +53,19 @@ class MetadataParser: def parseXML(self): if len(self.rawdata.getElementsByTagName('Series')) != 0: - self.data['Series'] = self.rawdata.getElementsByTagName('Series')[0].firstChild.nodeValue + self.data['Series'] = unescape(self.rawdata.getElementsByTagName('Series')[0].firstChild.nodeValue) if len(self.rawdata.getElementsByTagName('Volume')) != 0: self.data['Volume'] = self.rawdata.getElementsByTagName('Volume')[0].firstChild.nodeValue if len(self.rawdata.getElementsByTagName('Number')) != 0: self.data['Number'] = self.rawdata.getElementsByTagName('Number')[0].firstChild.nodeValue if len(self.rawdata.getElementsByTagName('Summary')) != 0: - self.data['Summary'] = self.rawdata.getElementsByTagName('Summary')[0].firstChild.nodeValue + self.data['Summary'] = unescape(self.rawdata.getElementsByTagName('Summary')[0].firstChild.nodeValue) if len(self.rawdata.getElementsByTagName('Title')) != 0: - self.data['Title'] = self.rawdata.getElementsByTagName('Title')[0].firstChild.nodeValue + self.data['Title'] = unescape(self.rawdata.getElementsByTagName('Title')[0].firstChild.nodeValue) for field in ['Writer', 'Penciller', 'Inker', 'Colorist']: if len(self.rawdata.getElementsByTagName(field)) != 0: for person in self.rawdata.getElementsByTagName(field)[0].firstChild.nodeValue.split(', '): - self.data[field + 's'].append(person) + self.data[field + 's'].append(unescape(person)) self.data[field + 's'] = list(set(self.data[field + 's'])) self.data[field + 's'].sort() if len(self.rawdata.getElementsByTagName('Page')) != 0: