Skip to content

Commit a0ff76b

Browse files
committed
feat(doc): add a new CDFV2 Microsoft Word filetype
1 parent 5ddaef8 commit a0ff76b

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

filetype/types/document.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ def match(self, buf):
124124
)
125125
):
126126
return True
127+
if (
128+
len(buf) > 663 and buf[512:531] == b"R\x00o\x00o\x00t\x00 \x00E\x00n\x00t\x00r\x00y"
129+
and buf[640:663] == b"W\x00o\x00r\x00d\x00D\x00o\x00c\x00u\x00m\x00e\x00n\x00t"
130+
):
131+
return True
127132

128133
return False
129134

tests/fixtures/sample_2.doc

1.64 KB
Binary file not shown.

tests/test_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_guess_zstd(self):
8989
self.assertEqual(kind.extension, 'zst')
9090

9191
def test_guess_doc(self):
92-
for name in 'sample.doc', 'sample_1.doc':
92+
for name in 'sample.doc', 'sample_1.doc', 'sample_2.doc':
9393
kind = filetype.guess(os.path.join(FIXTURES, name))
9494
self.assertIsNotNone(kind)
9595
self.assertEqual(kind.mime, 'application/msword')

0 commit comments

Comments
 (0)