mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
RTF metadata: Fix reading metadata from very small files
This commit is contained in:
parent
96e32a2def
commit
547e984acc
@ -25,12 +25,14 @@ def get_document_info(stream):
|
|||||||
while not found:
|
while not found:
|
||||||
prefix = block[-6:]
|
prefix = block[-6:]
|
||||||
block = prefix + stream.read(block_size)
|
block = prefix + stream.read(block_size)
|
||||||
|
actual_block_size = len(block) - len(prefix)
|
||||||
if len(block) == len(prefix):
|
if len(block) == len(prefix):
|
||||||
break
|
break
|
||||||
idx = block.find(r'{\info')
|
idx = block.find(r'{\info')
|
||||||
if idx >= 0:
|
if idx >= 0:
|
||||||
found = True
|
found = True
|
||||||
stream.seek(stream.tell() - block_size + idx - len(prefix))
|
pos = stream.tell() - actual_block_size + idx - len(prefix)
|
||||||
|
stream.seek(pos)
|
||||||
else:
|
else:
|
||||||
if block.find(r'\sect') > -1:
|
if block.find(r'\sect') > -1:
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user