From 699e56317f9ceb019660211fdde6887556fc7063 Mon Sep 17 00:00:00 2001 From: Sai Asish Y Date: Sun, 3 May 2026 05:30:55 +0000 Subject: [PATCH] fix: skip docx overrides pointing to missing parts Previously panicked with nil pointer dereference when a docx declared a content-type override for a PartName not present in the zip archive. Closes #170 Signed-off-by: SAY-5 --- docx.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docx.go b/docx.go index 185e52d..dd27aa4 100644 --- a/docx.go +++ b/docx.go @@ -62,7 +62,13 @@ func ConvertDocx(r io.Reader) (string, map[string]string, error) { meta := make(map[string]string) var textHeader, textBody, textFooter string for _, override := range contentTypeDefinition.Overrides { - f := zipFiles[override.PartName] + f, ok := zipFiles[override.PartName] + if !ok { + // Some docx files declare overrides for parts that are not + // present in the archive. Skip them rather than dereferencing + // a nil *zip.File and panicking. + continue + } switch { case override.ContentType == "application/vnd.openxmlformats-package.core-properties+xml":