From 4b7e24ec468276f104c87fe7add323f97d38c990 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 20 Apr 2020 08:45:55 +0530 Subject: [PATCH] DOCX Output: Fix internal links not working when converted files contain URL unsafe characters in their filenames --- src/calibre/ebooks/docx/writer/links.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/calibre/ebooks/docx/writer/links.py b/src/calibre/ebooks/docx/writer/links.py index 6eb80b8fd8..95c53d7c55 100644 --- a/src/calibre/ebooks/docx/writer/links.py +++ b/src/calibre/ebooks/docx/writer/links.py @@ -8,6 +8,7 @@ __copyright__ = '2015, Kovid Goyal ' import posixpath, re from uuid import uuid4 +from calibre.ebooks.oeb.base import urlquote from calibre.utils.filenames import ascii_text from polyglot.builtins import unicode_type from polyglot.urllib import urlparse @@ -118,6 +119,8 @@ class LinksManager(object): if not purl.scheme: href = item.abshref(href) + if href not in self.document_hrefs: + href = urlquote(href) if href in self.document_hrefs: key = (href, purl.fragment or self.top_anchor) if key in self.anchor_map: