[Libreoffice-commits] .: src/docstream.py
Miklos Vajna
vmiklos at kemper.freedesktop.org
Mon May 13 09:08:33 PDT 2013
src/docstream.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
New commits:
commit 004efbd436d0b520517eca847e270bdfa6cd08b6
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Mon May 13 18:08:26 2013 +0200
doc: don't hang when v6 is passed instead of v8
diff --git a/src/docstream.py b/src/docstream.py
index 195c0e4..6747084 100644
--- a/src/docstream.py
+++ b/src/docstream.py
@@ -10,6 +10,7 @@ import struct
from docdirstream import DOCDirStream
import docrecord
import globals
+import sys
class DOCFile:
"""Represents the whole word file - feed will all bytes."""
@@ -18,8 +19,16 @@ class DOCFile:
self.size = len(self.chars)
self.params = params
- self.header = ole.Header(self.chars, self.params)
- self.pos = self.header.parse()
+ if ord(self.chars[0]) == 0xD0 and ord(self.chars[1]) == 0xCF and ord(self.chars[2]) == 0x11 and ord(self.chars[3]) == 0xE0:
+ self.header = ole.Header(self.chars, self.params)
+ self.pos = self.header.parse()
+ else:
+ print '<?xml version="1.0"?>'
+ if ord(self.chars[0]) == 0xDB and ord(self.chars[1]) == 0xA5:
+ print '<todo what="handle v6 of the doc format"/>'
+ else:
+ print '<todo what="unhandled magic"/>'
+ sys.exit(0)
def __getDirectoryObj(self):
obj = self.header.getDirectory()
More information about the Libreoffice-commits
mailing list