From 26998b0a596103698bab8b46dbc427eccf89dc0a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 21 Dec 2020 10:58:14 +0530 Subject: [PATCH] AZW3 Input: Fix rare AID based links not working. Fixes #1898394 [Error generating TOC on AZW3 format](https://bugs.launchpad.net/calibre/+bug/1898394) --- src/calibre/ebooks/mobi/reader/markup.py | 2 +- src/calibre/ebooks/mobi/reader/mobi8.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/mobi/reader/markup.py b/src/calibre/ebooks/mobi/reader/markup.py index 4eb16daa1c..e18740b70e 100644 --- a/src/calibre/ebooks/mobi/reader/markup.py +++ b/src/calibre/ebooks/mobi/reader/markup.py @@ -335,7 +335,7 @@ def expand_mobi8_markup(mobi8_reader, resource_map, log): parts = update_internal_links(mobi8_reader, log) # Remove pointless markup inserted by kindlegen - remove_kindlegen_markup(parts, mobi8_reader.aid_anchor_suffix, mobi8_reader.linked_aids) + remove_kindlegen_markup(parts, mobi8_reader.aid_anchor_suffix.decode('utf-8'), mobi8_reader.linked_aids) # Handle substitutions for the flows pieces first as they may # be inlined into the xhtml text diff --git a/src/calibre/ebooks/mobi/reader/mobi8.py b/src/calibre/ebooks/mobi/reader/mobi8.py index e87c3369bc..68ab3037b9 100644 --- a/src/calibre/ebooks/mobi/reader/mobi8.py +++ b/src/calibre/ebooks/mobi/reader/mobi8.py @@ -337,7 +337,7 @@ class Mobi8Reader(object): # See https://www.mobileread.com/forums/showthread.php?t=259557 m = self.aid_re.match(tag) if m is not None: - self.linked_aids.add(m.group(1)) + self.linked_aids.add(m.group(1).decode('utf-8')) return m.group(1) + b'-' + self.aid_anchor_suffix # No tag found, link to start of file