Repository navigation
NuGet: read .nuspec manifests in UTF-16 with a byte-order mark - #865
Merged
Merged
Conversation
parse_nupkg refused a manifest in UTF-16 LE with a byte-order mark (Microsoft.Web.Infrastructure 1.0.0 on nuget.org), so it could neither be pushed nor served through a proxy of nuget.org. The manifest is now decoded the way NuGet's XDocument.Load reads it: a UTF-16 LE or BE mark is decoded, a UTF-8 mark is dropped, and every other check still runs on the decoded text. The stored manifest keeps the package's own bytes. Adds a UTF-16 manifest fixture (fixtures/nuget/make_fixtures.py). Fixes #597 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012e6DJaoNeeYjbTdvTzQ728
schmitch
enabled auto-merge
November 3, 2026 21:28
Member
Author
|
CI I don't think this failure comes from this PR:
I've re-run the failed job once to confirm. There is no fix for that test to port into this PR. If it fails again, I'll report it as a separate issue rather than widen this PR. Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #597
What
parse_nupkgrefused a manifest in UTF-16 LE with a byte-order mark (Microsoft.Web.Infrastructure1.0.0 on nuget.org) withcannot decode input using UTF-8. Because of that, the package could not be pushed, and a proxy of nuget.org could not serve it.parse_nuspec(crates/formats/nuget/src/nuspec.rs) now runs every manifest through a newdecode_manifestfirst. It reads the manifest the way NuGet'sXDocument.Loaddoes:FF FE) or BE (FE FF) byte-order mark: the rest is decoded to UTF-8. An odd byte count or an unpaired surrogate is refused as a malformed manifest.EF BB BF): the mark is dropped.Every other check (DOCTYPE, depth, identity, ids, versions, limits) then runs on the decoded text. The size limits still apply to the raw bytes. All callers go through
parse_nuspec: push, proxy manifest verification (manifest_identity), registration dependency groups and display metadata. The stored manifest keeps the package's own bytes, so it is served unchanged.Tests
fixtures/nuget/utf16.package.1.0.0.nupkg, generated byfixtures/nuget/make_fixtures.py. Its manifest is UTF-16 LE with a BOM,encoding="utf-16"and non-ASCII text. It is the only fixture added; the existing fixtures are left unchanged.tests/parse.rs::parses_a_utf16_manifest_with_a_byte_order_markparses the fixture end to end and reads the metadata back from the stored manifest.nuspec.rs:manifests_with_a_byte_order_mark_are_decoded_as_nuget_doescovers UTF-16 LE, UTF-16 BE and UTF-8 with a BOM.malformed_utf16_manifests_are_refusedcovers an odd byte count and an unpaired surrogate, and checks that the DOCTYPE refusal still applies after decoding.cargo fmt --all --check,cargo clippy -p forge-format-nuget --all-targets -- -D warnings,cargo test -p forge-format-nugetandcargo xtask changelog --check.Changelog
docs/changes/2.2.0/597.fixed.mdGenerated by Claude Code