FB2 Input: Dont choke on FB2 files that have empty embedded content tags. Fixes #880904 (can't view fb2 file - 'NoneType' object has no attribute 'strip')

This commit is contained in:
Kovid Goyal 2011-10-24 22:11:40 +05:30
parent 5b600f708a
commit 25b5a61e68

View File

@ -127,7 +127,7 @@ class FB2Input(InputFormatPlugin):
def extract_embedded_content(self, doc): def extract_embedded_content(self, doc):
self.binary_map = {} self.binary_map = {}
for elem in doc.xpath('./*'): for elem in doc.xpath('./*'):
if 'binary' in elem.tag and elem.attrib.has_key('id'): if elem.text and 'binary' in elem.tag and elem.attrib.has_key('id'):
ct = elem.get('content-type', '') ct = elem.get('content-type', '')
fname = elem.attrib['id'] fname = elem.attrib['id']
ext = ct.rpartition('/')[-1].lower() ext = ct.rpartition('/')[-1].lower()