Repository navigation
Reject raw URI delimiters in OPC part names - #1069
Merged
Merged
Conversation
Reject raw fragment and query delimiters in ZIP entry names before signing while preserving percent-encoded forms in package paths and signature references. Add dynamic OPC package coverage and verify rejected packages remain unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Restore the existing URI helper behavior and remove encoded-reference signing assertions so this branch remains limited to rejecting raw OPC URI delimiters. Retain validator-level coverage that percent-encoded delimiters are not rejected. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Reject decoded raw URI delimiters before CreatePart updates content types or archive entries, preserving package state when validation fails. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The validation occurs before URI interpretation or package mutation and is covered by focused regression tests.
Review tier: Balanced
Findings: None
What changed in this PR
Adds focused validation to prevent malformed OPC signatures caused by raw URI delimiters in ZIP entry names.
Changes:
- Rejects raw
#and?before constructing or creating OPC parts. - Adds localized diagnostics identifying the offending name and delimiter.
- Adds signing, package-integrity, valid-name, and percent-encoding tests.
| File | Description |
|---|---|
test/Sign.Core.Test/Tools/VSIXSignTool/OpcPackageTests.cs |
Tests safe rejection during part creation. |
test/Sign.Core.Test/Tools/VSIXSignTool/OpcPackageSigningTests.cs |
Tests signing behavior and archive integrity. |
src/Sign.Core/Tools/VsixSignTool/OpcPartNameValidator.cs |
Implements delimiter validation. |
src/Sign.Core/Tools/VsixSignTool/OpcPart.cs |
Validates ZIP entry names before URI construction. |
src/Sign.Core/Tools/VsixSignTool/OpcPackage.cs |
Validates newly created part paths. |
src/Sign.Core/Resources.resx |
Adds the validation error resource. |
src/Sign.Core/Resources.Designer.cs |
Exposes the generated resource property. |
src/Sign.Core/xlf/Resources.cs.xlf |
Adds Czech localization metadata. |
src/Sign.Core/xlf/Resources.de.xlf |
Adds German localization metadata. |
src/Sign.Core/xlf/Resources.es.xlf |
Adds Spanish localization metadata. |
src/Sign.Core/xlf/Resources.fr.xlf |
Adds French localization metadata. |
src/Sign.Core/xlf/Resources.it.xlf |
Adds Italian localization metadata. |
src/Sign.Core/xlf/Resources.ja.xlf |
Adds Japanese localization metadata. |
src/Sign.Core/xlf/Resources.ko.xlf |
Adds Korean localization metadata. |
src/Sign.Core/xlf/Resources.pl.xlf |
Adds Polish localization metadata. |
src/Sign.Core/xlf/Resources.pt-BR.xlf |
Adds Brazilian Portuguese localization metadata. |
src/Sign.Core/xlf/Resources.ru.xlf |
Adds Russian localization metadata. |
src/Sign.Core/xlf/Resources.tr.xlf |
Adds Turkish localization metadata. |
src/Sign.Core/xlf/Resources.zh-Hans.xlf |
Adds Simplified Chinese localization metadata. |
src/Sign.Core/xlf/Resources.zh-Hant.xlf |
Adds Traditional Chinese localization metadata. |
Files not reviewed (1)
- src/Sign.Core/Resources.Designer.cs: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
pjcollins
approved these changes
Sep 14, 2026
This was referenced Sep 28, 2026
Closed
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 #998.
Summary
Reject raw
#and?characters in OPC part names before a ZIP entry name is interpreted as a relative package URI. Without this validation,System.Uritreats these characters as fragment and query delimiters, so the signature can reference a different path than the entry whose content was digested.This change:
ZipArchiveEntry.FullNamebefore constructing anOpcPartURI;#/?names are rejected, no signature is produced, and package entries remain unchanged;%23/%3Ftext for raw delimiters.Scope
This is deliberately limited validation, not complete syntactic or semantic OPC part-name validation.
The change follows the rejection approach contributed in #1047 and preserves the original contributor's commits and authorship.
Testing
All discovered solution tests pass: 769 passed, 1 skipped, 0 failed.
This change adds 4 test methods covering 12 test cases.