From 5b4984ff3091c2a8765e5cd956bc55f352139b25 Mon Sep 17 00:00:00 2001 From: SAY-5 Date: Sat, 2 May 2026 22:30:55 -0700 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":