Fix missing rels content-type registration causing null MainDocumentPart#2090
Fix missing rels content-type registration causing null MainDocumentPart#2090rakeshbabuseva wants to merge 1 commit into
Conversation
Some OOXML generators omit the required `<Default Extension="rels" .../>` entry from `[Content_Types].xml`. System.IO.Packaging is strict: without that registration it cannot resolve .rels parts, so the package relationship walk never finds the officeDocument relationship and MainDocumentPart comes back null. RepairRelsContentType() in StreamPackageFeature detects this deviation before Package.Open and rebuilds the stream with the missing entry injected into [Content_Types].xml. All other ZIP entries are streamed verbatim. The repair is a no-op for well-formed packages. Gated on !NETFRAMEWORK because ZipArchive is not available on net35/net40 and the old System.IO.Packaging on those targets is already lenient. Fixes: WordprocessingDocument.Open returns null MainDocumentPart when [Content_Types].xml omits Default Extension="rels"
@dotnet-policy-service agree |
Some OOXML generators omit the required
<Default Extension="rels" .../>entry from[Content_Types].xml. System.IO.Packaging is strict: without that registration it cannot resolve .rels parts, so the package relationship walk never finds the officeDocument relationship and MainDocumentPart comes back null.RepairRelsContentType() in StreamPackageFeature detects this deviation before Package.Open and rebuilds the stream with the missing entry injected into [Content_Types].xml. All other ZIP entries are streamed verbatim. The repair is a no-op for well-formed packages. Gated on !NETFRAMEWORK because ZipArchive is not available on net35/net40 and the old System.IO.Packaging on those targets is already lenient.
Fixes: WordprocessingDocument.Open returns null MainDocumentPart when [Content_Types].xml omits Default Extension="rels"