pdfinfo: more robustness

This commit is contained in:
James R. Barlow
2018-07-04 17:12:30 -07:00
parent 216d60ea2c
commit 5cc23dbf24
+7 -1
View File
@@ -521,7 +521,13 @@ def _page_get_textblocks(infile, pageno):
# are only generated as innermost self-closing tags.
gstext = regex_remove_char_tags.sub(b' ', gstext)
root = ET.fromstring(gstext)
if gstext.strip() == '':
return []
try:
root = ET.fromstring(gstext)
except ET.ParseError as e:
return [] # If we can't parse, assume none...
def blocks():
for span in root.findall('.//span'):