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: