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":