-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Description
Previously, part names and overrides that differed only by ASCII case (e.g. /part vs /PART) were not considered equivalent, even though the Open Packaging Conventions (OPC) specification requires case-insensitive equivalence (§7.2.3.5, ECMA-376).
This change fixes the bug reported in dotnet/runtime#112783
and brings .NET 5–9 in line with both .NET Framework and the OPC spec.
Version
.NET 8
Previous behavior
URI comparisons were case-sensitive.
Content type overrides failed if the casing differed between the part URI and the override entry.
Some non-compliant packages containing duplicate entries differing only in case (e.g. /part and /PART) could be loaded, leading to ambiguous results.
New behavior
URI comparisons are case-insensitive (StringComparison.OrdinalIgnoreCase).
Overrides with different casing now work as expected.
Non-compliant packages containing multiple entries that differ only by case are now rejected when opened. This aligns with .NET Framework and the OPC specification.
Type of breaking change
- Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
- Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
- Behavioral change: Existing binaries might behave differently at run time.
Reason for change
Aligns System.IO.Packaging behavior with:
- The OPC specification (case-insensitive URI equivalence is mandatory).
- Existing .NET Framework behavior, which already enforces case-insensitive matching.
Prevents ambiguous lookups and ensures consistent results.
Fixes dotnet/runtime#112783.
Recommended action
Ensure that OPC packages do not contain part names differing only by case, as this is invalid per the OPC specification.
If consuming packages that violate the spec:
- Contact the package author to fix the package.
- If you need to read or inspect the contents, you can open the package as a ZIP archive. Unlike the Package API, ZIP archives do not enforce OPC rules and will allow you to access all entries, including those with conflicting case names.
Feature area
Core .NET libraries
Affected APIs
System.IO.Packaging.Package.GetPart(Uri)
System.IO.Packaging.Package.CreatePart(Uri, string)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status