Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(ocr): support legacy application/x-epub+zip MIME type
Elian Doran2258264a2da9
diff --git a/apps/server/src/services/ocr/processors/office_processor.integration.spec.ts b/apps/server/src/services/ocr/processors/office_processor.integration.spec.tsindex 2e6c09d349..31762a0112 100644--- a/apps/server/src/services/ocr/processors/office_processor.integration.spec.ts+++ b/apps/server/src/services/ocr/processors/office_processor.integration.spec.ts@@ -69,8 +69,8 @@ const EPUB_PHRASES = [// Each sample exercises a distinct officeparser code path: DOCX -> WordParser,// XLSX -> ExcelParser, PPTX -> PowerPointParser, ODT/ODS/ODP -> OpenOfficeParser// (text / spreadsheet / presentation element handling), RTF -> RtfParser and-// EPUB -> EpubParser (both routed via an explicit fileType hint), with OOXML vs.-// ODF vs. EPUB magic-byte detection on top.+// EPUB -> EpubParser (both routed via an explicit fileType hint to bypass the+// ambiguous ZIP/PK magic bytes shared with OOXML and ODF).const SAMPLES = [{ label: 'DOCX', file: 'demo.docx', mimeType: DOCX, phrases: DOCUMENT_PHRASES },{ label: 'XLSX', file: 'demo.xlsx', mimeType: XLSX, phrases: SPREADSHEET_PHRASES },diff --git a/apps/server/src/services/ocr/processors/office_processor.spec.ts b/apps/server/src/services/ocr/processors/office_processor.spec.tsindex 97954820d6..88d6edc92e 100644--- a/apps/server/src/services/ocr/processors/office_processor.spec.ts+++ b/apps/server/src/services/ocr/processors/office_processor.spec.ts@@ -45,6 +45,7 @@ describe('OfficeProcessor', () => {expect(processor.canProcess(RTF)).toBe(true);expect(processor.canProcess('text/rtf')).toBe(true);expect(processor.canProcess(EPUB)).toBe(true);+ expect(processor.canProcess('application/x-epub+zip')).toBe(true);expect(processor.canProcess('application/pdf')).toBe(false);expect(processor.getSupportedMimeTypes()).toContain(DOCX);expect(processor.getProcessingType()).toBe('office');diff --git a/apps/server/src/services/ocr/processors/office_processor.ts b/apps/server/src/services/ocr/processors/office_processor.tsindex c35809e7c4..7bb2e130ff 100644--- a/apps/server/src/services/ocr/processors/office_processor.ts+++ b/apps/server/src/services/ocr/processors/office_processor.ts@@ -17,7 +17,8 @@ const SUPPORTED_MIME_TYPES = new Set(['application/rtf','text/rtf',// E-book- 'application/epub+zip'+ 'application/epub+zip',+ 'application/x-epub+zip']);const PARSER_CONFIG: OfficeParserConfig = {@@ -36,7 +37,8 @@ const PARSER_CONFIG: OfficeParserConfig = {const MIME_TYPE_TO_FILE_TYPE: Record<string, SupportedFileType> = {'application/rtf': 'rtf','text/rtf': 'rtf',- 'application/epub+zip': 'epub'+ 'application/epub+zip': 'epub',+ 'application/x-epub+zip': 'epub'};/**