From 39c18eb51cf1a0156b5e09ef2d68b5dee6f0680e Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 5 Dec 2026 11:30:30 +0000 Subject: Handle main document part without a root element --- lib/docx/docx-reader.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib') diff --git a/lib/docx/docx-reader.js b/lib/docx/docx-reader.js index f343dae..9bca76b 100644 --- a/lib/docx/docx-reader.js +++ b/lib/docx/docx-reader.js @@ -74,6 +74,10 @@ function read(docxFile, input, options) { }; }).then(function(result) { return readXmlFileWithBody(result.partPaths.mainDocument, result, function(bodyReader, xml) { + if (xml === null) { + throw new Error("Main document part is missing root element. Are you sure this is a valid .docx file?"); + } + return result.notes.flatMap(function(notes) { return result.comments.flatMap(function(comments) { var reader = new DocumentXmlReader({ -- cgit v1.2.3