From 6abbf2221e3928c8145cc641c581e3919842d9eb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 16 Oct 2019 18:26:08 +0530 Subject: [PATCH] Viewer: Fix an error when processing a CFI with an invalid text offset. Fixes #1848320 [E-book viewer - Error: Unhandled error](https://bugs.launchpad.net/calibre/+bug/1848320) --- src/pyj/read_book/cfi.pyj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyj/read_book/cfi.pyj b/src/pyj/read_book/cfi.pyj index 221d62acea..513ca6ad37 100644 --- a/src/pyj/read_book/cfi.pyj +++ b/src/pyj/read_book/cfi.pyj @@ -468,7 +468,7 @@ def point(cfi, doc): # {{{ try_list = [{'start':0, 'end':0, 'a':0.5}, {'start':-1, 'end':0, 'a':0}, {'start':0, 'end':1, 'a':1}] a = None rects = None - node_len = node.nodeValue.length + node_len = node.nodeValue.length if node.nodeValue else 0 offset = r.offset for v'var i = 0; i < 2; i++': # Try reducing the offset by 1 if we get no match as if it refers to the position after the