From 8f18065d3c484f8b9765ee084fa5f46243c3cf0f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 27 Mar 2011 21:06:16 -0600 Subject: [PATCH] RTF Input: Handle RTF files with too many levels of list nesting. Fixes #743243 (IndexError: list index out of range Converting RTF to EPUB, LRF) --- src/calibre/ebooks/rtf2xml/make_lists.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/rtf2xml/make_lists.py b/src/calibre/ebooks/rtf2xml/make_lists.py index fc544ac499..b785bf85d2 100755 --- a/src/calibre/ebooks/rtf2xml/make_lists.py +++ b/src/calibre/ebooks/rtf2xml/make_lists.py @@ -291,9 +291,12 @@ class MakeLists: if self.__list_of_lists: # older RTF won't generate a list_of_lists index_of_list = self.__get_index_of_list(id) if index_of_list != None:# found a matching id - list_dict = self.__list_of_lists[index_of_list][0] + curlist = self.__list_of_lists[index_of_list] + list_dict = curlist[0] level = int(self.__level) + 1 - level_dict = self.__list_of_lists[index_of_list][level][0] + if level >= len(curlist): + level = len(curlist) - 1 + level_dict = curlist[level][0] list_type = level_dict.get('numbering-type') if list_type == 'bullet': list_type = 'unordered'