From b72a3f8e798afa212a064c61aaca4bf2f56394ac Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 16 Sep 2013 19:09:53 +0530 Subject: [PATCH] AZW3 Output: Dont choke on invalid links in the input document --- src/calibre/ebooks/mobi/writer8/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/mobi/writer8/main.py b/src/calibre/ebooks/mobi/writer8/main.py index e1e0981af1..00550d78d4 100644 --- a/src/calibre/ebooks/mobi/writer8/main.py +++ b/src/calibre/ebooks/mobi/writer8/main.py @@ -230,7 +230,11 @@ class KF8Writer(object): count += 1 ref = item.abshref(a.get('href')) href, _, frag = ref.partition('#') - href = urlnormalize(href) + try: + href = urlnormalize(href) + except ValueError: + # a non utf-8 quoted url? Since we cannot interpret it, pass it through. + pass if href in hrefs: placeholder = 'kindle:pos:fid:0000:off:%s'%to_href(count) self.link_map[placeholder] = (href, frag)