diff --git a/test_unstructured/file_utils/test_filetype.py b/test_unstructured/file_utils/test_filetype.py index cecc8983be..e5dbf94522 100644 --- a/test_unstructured/file_utils/test_filetype.py +++ b/test_unstructured/file_utils/test_filetype.py @@ -968,6 +968,25 @@ def it_distinguishes_the_file_type_of_applicable_CFB_files( assert _OleFileDetector.file_type(ctx) is expected_value + def it_detects_confluence_exported_doc_files(self, monkeypatch: pytest.MonkeyPatch): + """Detect Confluence-exported DOC files that store content in FileContents.""" + with open(example_doc_path("simple.doc"), "rb") as f: + file = io.BytesIO(f.read()) + ctx = _FileTypeDetectionContext(file=file) + + class MockStream: + name = "FileContents" + + class MockStorage: + streams = [MockStream()] + + monkeypatch.setattr( + "unstructured.file_utils.filetype.Storage.from_ole", + lambda _: MockStorage(), + ) + + assert _OleFileDetector.file_type(ctx) is FileType.DOC + class Describe_TextFileDifferentiator: """Unit-test suite for `unstructured.file_utils.filetype._TextFileDifferentiator`.""" diff --git a/unstructured/file_utils/filetype.py b/unstructured/file_utils/filetype.py index b813f3d26d..e559b1a910 100644 --- a/unstructured/file_utils/filetype.py +++ b/unstructured/file_utils/filetype.py @@ -715,6 +715,9 @@ def _ole_file_type(self) -> FileType | None: for stream in root_storage.streams: if stream.name == "WordDocument": return FileType.DOC + elif stream.name == "FileContents": + # Confluence-exported legacy DOC files store content in this stream. + return FileType.DOC elif stream.name == "PowerPoint Document": return FileType.PPT elif stream.name == "Workbook":