[ooo-build-commit] scratch/mso-dumper

Kohei Yoshida kohei at kemper.freedesktop.org
Wed Sep 23 13:41:51 PDT 2009


 scratch/mso-dumper/src/xlsrecord.py |   25 +++++++++++++++++++++++++
 scratch/mso-dumper/src/xlsstream.py |   14 ++++++++++----
 2 files changed, 35 insertions(+), 4 deletions(-)

New commits:
commit 18ad7ab273fb7b051acfd16846825078f094038d
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Sep 23 16:39:44 2009 -0400

    [xls-dump] Disable record parsing on encrypted streams.
    
    * scratch/mso-dumper/src/xlsrecord.py:
    * scratch/mso-dumper/src/xlsstream.py: if the FILEPASS record
      is present, set the encrypted flag on, and disable record
      parsing from this point on.

diff --git a/scratch/mso-dumper/src/xlsrecord.py b/scratch/mso-dumper/src/xlsrecord.py
index cd137a6..7bc856b 100644
--- a/scratch/mso-dumper/src/xlsrecord.py
+++ b/scratch/mso-dumper/src/xlsrecord.py
@@ -214,6 +214,31 @@ class Dimensions(BaseRecordHandler):
         self.appendLine("last defined column plus 1: %d"%colMac)
 
 
+class FilePass(BaseRecordHandler):
+
+    def parseBytes (self):
+        mode = self.readUnsignedInt(2)    # mode: 0 = BIFF5  1 = BIFF8
+        self.readUnsignedInt(2)           # ignore 2 bytes.
+        subMode = self.readUnsignedInt(2) # submode: 1 = standard encryption  2 = strong encryption
+
+        modeName = 'unknown'
+        if mode == 0:
+            modeName = 'BIFF5'
+        elif mode == 1:
+            modeName = 'BIFF8'
+
+        encType = 'unknown'
+        if subMode == 1:
+            encType = 'standard'
+        elif subMode == 2:
+            encType = 'strong'
+        
+        self.appendLine("mode: %s"%modeName)
+        self.appendLine("encryption type: %s"%encType)
+        self.appendLine("")
+        self.appendMultiLine("NOTE: Since this document appears to be encrypted, the dumper will not parse the record contents from this point forward.")
+
+
 class Formula(BaseRecordHandler):
 
     def parseBytes (self):
diff --git a/scratch/mso-dumper/src/xlsstream.py b/scratch/mso-dumper/src/xlsstream.py
index 1d79bed..11e4b65 100644
--- a/scratch/mso-dumper/src/xlsstream.py
+++ b/scratch/mso-dumper/src/xlsstream.py
@@ -37,7 +37,7 @@ recData = {
     0x0029: ["BOTTOMMARGIN", "Bottom Margin Measurement"],
     0x002A: ["PRINTHEADERS", "Print Row/Column Labels"],
     0x002B: ["PRINTGRIDLINES", "Print Gridlines Flag"],
-    0x002F: ["FILEPASS", "File Is Password-Protected"],
+    0x002F: ["FILEPASS", "File Is Password-Protected", xlsrecord.FilePass],
     0x0031: ["FONT", "Font and Character Formatting"],
     0x003C: ["CONTINUE", "Continues Long Records"],
     0x003D: ["WINDOW1", "Window Information"],
@@ -408,7 +408,7 @@ class XLDirStream(object):
         # record handler that parses the raw bytes and displays more 
         # meaningful information.
         handler = None 
-
+        
         print("")
         self.__printSep('=', 61, "%4.4Xh: "%header)
         if recData.has_key(header):
@@ -439,8 +439,14 @@ class XLDirStream(object):
         if size > 0:
             print("")
 
-        if handler != None:
-            # record handler exists.  Parse the record and display more info.
+        if handler != None and not self.strmData.encrypted:
+            # record handler exists.  Parse the record and display more info 
+            # unless the stream is encrypted.
             handler.output()
 
+        if recData.has_key(header) and recData[header][0] == "FILEPASS":
+            # presence of FILEPASS record indicates that the stream is 
+            # encrypted.
+            self.strmData.encrypted = True
+
         return header


More information about the ooo-build-commit mailing list