diff --git a/tests/ooxml/test_basic.py b/tests/ooxml/test_basic.py
index f25d7f4..e850389 100644
--- a/tests/ooxml/test_basic.py
+++ b/tests/ooxml/test_basic.py
@@ -10,18 +10,24 @@ from oletools import ooxml
class TestOOXML(unittest.TestCase):
- """ Tests my cool new feature """
+ """ Tests correct detection of doc type """
DO_DEBUG = False
def test_all_rough(self):
"""Checks all samples, expect either ole files or good ooxml output"""
- acceptable = ooxml.DOCTYPE_EXCEL, ooxml.DOCTYPE_WORD, \
- ooxml.DOCTYPE_POWERPOINT
+ # map from extension to expected doctype
+ ext2doc = dict(
+ docx=ooxml.DOCTYPE_WORD, docm=ooxml.DOCTYPE_WORD,
+ xml=(ooxml.DOCTYPE_EXCEL_XML, ooxml.DOCTYPE_WORD_XML),
+ xlsx=ooxml.DOCTYPE_EXCEL, xlsm=ooxml.DOCTYPE_EXCEL,
+ xlsb=ooxml.DOCTYPE_EXCEL,
+ pptx=ooxml.DOCTYPE_POWERPOINT, pptm=ooxml.DOCTYPE_POWERPOINT,
+ )
# files that are neither OLE nor xml:
except_files = 'empty', 'text'
- except_extns = '.xml', '.rtf', '.csv'
+ except_extns = 'rtf'
# analyse all files in data dir
for base_dir, _, files in os.walk(DATA_BASE_DIR):
@@ -30,7 +36,10 @@ class TestOOXML(unittest.TestCase):
if self.DO_DEBUG:
print('skip file: ' + filename)
continue
- if splitext(filename)[1] in except_extns:
+ extn = splitext(filename)[1]
+ if extn:
+ extn = extn[1:] # remove the dot
+ if extn in except_extns:
if self.DO_DEBUG:
print('skip extn: ' + filename)
continue
@@ -40,6 +49,9 @@ class TestOOXML(unittest.TestCase):
if self.DO_DEBUG:
print('skip ole: ' + filename)
continue
+ acceptable = ext2doc[extn]
+ if not isinstance(acceptable, tuple):
+ acceptable = (acceptable, )
try:
doctype = ooxml.get_type(full_name)
except Exception:
diff --git a/tests/test-data/ooxml/dde-in-excel2003.xml b/tests/test-data/ooxml/dde-in-excel2003.xml
new file mode 100644
index 0000000..b24aef7
--- /dev/null
+++ b/tests/test-data/ooxml/dde-in-excel2003.xml
@@ -0,0 +1,101 @@
+
+
+
+
+ user
+ user
+ 2018-01-04T17:55:47Z
+ 11.9999
+
+
+
+ cmd|/c calc.exe
+
+ A1
+
+
+
+ StdDocumentName
+
+
+
+
+ 12840
+ 15315
+ 360
+ 105
+ False
+ False
+
+
+
+
+
+
+
+ | This spread sheet has a dde link which starts calc.exe |
+
+
+ | #REF! |
+
+
+
+
+
+
+
+
+
+
+
+ 3
+ 1
+ 2
+
+
+ False
+ False
+
+
+
+
+
+
+
+
+
+
+ False
+ False
+
+
+
+
+
+
+
+
+
+
+ False
+ False
+
+
+
diff --git a/tests/test-data/ooxml/dde-in-word2003.xml b/tests/test-data/ooxml/dde-in-word2003.xml
new file mode 100644
index 0000000..c323b30
--- /dev/null
+++ b/tests/test-data/ooxml/dde-in-word2003.xml
@@ -0,0 +1,3 @@
+
+
+useruser202018-01-04T17:21:00Z2018-01-04T17:21:00Z11277118811.0000DDEAUTO c:\\windows\\system32\\cmd.exe "/k calc.exe"!Unerwartetes Ende des Ausdrucks
\ No newline at end of file
diff --git a/tests/test-data/ooxml/harmless-clean-2003.xml b/tests/test-data/ooxml/harmless-clean-2003.xml
new file mode 100644
index 0000000..477069f
--- /dev/null
+++ b/tests/test-data/ooxml/harmless-clean-2003.xml
@@ -0,0 +1,3 @@
+
+
+useruser202017-10-26T09:10:00Z2017-10-26T09:10:00Z1392502128816TestThis is a harmless test document.It contains neither macros nor dde links nor embedded viruses nor links to evil web pages. Not even a single insult. Boring!Just to make things slightly interesting, however, we add some ünicöde-ßtringß and different text sizes, colors and fonts
\ No newline at end of file
diff --git a/tests/test-data/ooxml/harmless-clean.xml b/tests/test-data/ooxml/harmless-clean.xml
new file mode 100644
index 0000000..cd1e53c
--- /dev/null
+++ b/tests/test-data/ooxml/harmless-clean.xml
@@ -0,0 +1,3 @@
+
+
+TestThis is a harmless test document.It contains neither macros nor dde links nor embedded viruses nor links to evil web pages. Not even a single insult. Boring!Just to make things slightly interesting, however, we add some ünicöde-ßtringß and different text sizes, colors and fontsNormal0139250Microsoft Office Word021falseTitel1false288falsefalse16.0000useruser22017-10-26T09:10:00Z2017-10-26T09:10:00Z
\ No newline at end of file