From 88ff4ae12624431b0279ebe7f14c7f9162116736 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 12 May 2016 15:43:10 +0530 Subject: [PATCH] Edit Book: Fix a crash in the Insert Link tool if one of the HTML files contains an empty id. Fixes #1580928 [id=""](https://bugs.launchpad.net/calibre/+bug/1580928) --- src/calibre/gui2/tweak_book/widgets.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/gui2/tweak_book/widgets.py b/src/calibre/gui2/tweak_book/widgets.py index 30321e1adc..9b604de6fc 100644 --- a/src/calibre/gui2/tweak_book/widgets.py +++ b/src/calibre/gui2/tweak_book/widgets.py @@ -670,6 +670,8 @@ class InsertLink(Dialog): ac = self.anchor_cache[name] = [] for item in set(root.xpath('//*[@id]')) | set(root.xpath('//h:a[@name]', namespaces={'h':XHTML_NS})): frag = item.get('id', None) or item.get('name') + if not frag: + continue text = lead_text(item, num_words=4) ac.append((text, frag)) ac.sort(key=lambda text_frag: primary_sort_key(text_frag[0]))