fix(preview): stop routing legacy .doc/.ppt to the OOXML previewers

main
dzc-bit 2026-09-06 00:59:46 +08:00 committed by lyingbug
parent 01377b686c
commit 25a930b9a0
2 changed files with 12 additions and 2 deletions

View File

@ -27,6 +27,12 @@ test('resolvePreviewKind covers office, tables, html, media, and code', () => {
assert.equal(resolvePreviewKind('pdf'), 'pdf')
assert.equal(resolvePreviewKind('docx'), 'docx')
assert.equal(resolvePreviewKind('pptx'), 'pptx')
// Legacy OLE2 formats are not parseable by the OOXML previewers and must
// degrade to the unsupported state instead of failing with a zip error.
assert.equal(resolvePreviewKind('doc'), 'unsupported')
assert.equal(resolvePreviewKind('ppt'), 'unsupported')
// SheetJS renders legacy .xls fine, so it stays previewable.
assert.equal(resolvePreviewKind('xls'), 'excel')
assert.equal(resolvePreviewKind('png'), 'image')
assert.equal(resolvePreviewKind('svg'), 'image')
assert.equal(resolvePreviewKind('md'), 'markdown')

View File

@ -36,8 +36,12 @@ function register(kind: FilePreviewKind, exts: string[]) {
}
register('pdf', ['pdf'])
register('docx', ['docx', 'doc'])
register('pptx', ['pptx', 'ppt'])
// .doc (Word 97-2003) and .ppt (PowerPoint 97-2003) are legacy OLE2 binary
// formats, while the docx/pptx previewers only parse OOXML (ZIP/XML) and
// would fail with a raw zip error; leaving them unregistered degrades to the
// unsupported-preview state with a download entry instead.
register('docx', ['docx'])
register('pptx', ['pptx'])
register('image', [
'jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff', 'tif', 'svg', 'svgz',
'ico', 'avif', 'apng', 'jfif', 'pjpeg', 'pjp', 'heic', 'heif',