From de0631f9270560a0a25ef94bdb56e4df4092ad25 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 30 Nov 2009 12:53:03 -0700 Subject: [PATCH] Fix #4108 (Bug when convertinf an LRF file to MOBI) --- Changelog.yaml | 3 +++ src/calibre/ebooks/lrf/objects.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Changelog.yaml b/Changelog.yaml index 0de35f324c..5ff3b1969d 100644 --- a/Changelog.yaml +++ b/Changelog.yaml @@ -55,6 +55,9 @@ - title: "LIT Input: Remove more invalid markup present in LIT files created by Microsoft Word plugins" tickets: [4087] + - title: "LRF Input: Workaround buggy LRF files with unbalanced closing tags" + tickets: [4108] + new recipes: - title: The Economist (no subscription required) author: Kovid Goyal diff --git a/src/calibre/ebooks/lrf/objects.py b/src/calibre/ebooks/lrf/objects.py index ae9736a2f8..93be0f3143 100644 --- a/src/calibre/ebooks/lrf/objects.py +++ b/src/calibre/ebooks/lrf/objects.py @@ -872,8 +872,9 @@ class Text(LRFStream): if isinstance(c, basestring): s += c elif c is None: - p = open_containers.pop() - s += u''%(p.name,) + if open_containers: + p = open_containers.pop() + s += u''%(p.name,) else: s += unicode(c) if not c.self_closing: