Skip to content

Percent-encode VERS metacharacters in ToVersString output#16

Merged
andrew merged 1 commit into
mainfrom
fix/vers-string-encoding
May 2, 2026
Merged

Percent-encode VERS metacharacters in ToVersString output#16
andrew merged 1 commit into
mainfrom
fix/vers-string-encoding

Conversation

@andrew
Copy link
Copy Markdown
Contributor

@andrew andrew commented May 2, 2026

`ToVersString` emits version strings verbatim. If a version contains `|`, `>`, `<`, `=`, or `!`, the output is ambiguous: `Parse(ToVersString(r))` can split or reinterpret these characters as constraint boundaries, widening or changing the range.

Adds `encodeVersVersion` which percent-encodes VERS metacharacters in version strings before they're placed in the output. Adds a matching decode step in `parseConstraintWithScheme` using `url.PathUnescape`, so roundtripping through `ToVersString` then `Parse` preserves the original range.

Version strings containing | or operator characters (>, <, =, !) are
output verbatim by ToVersString, causing Parse(ToVersString(r)) to
split or interpret them as constraint boundaries. Encodes these
characters in the output and decodes them when parsing constraints,
so roundtripping preserves the original range.
@andrew andrew force-pushed the fix/vers-string-encoding branch from 7f65be8 to f7a600e Compare May 2, 2026 15:33
@andrew andrew merged commit 6aeac1c into main May 2, 2026
2 checks passed
@andrew andrew deleted the fix/vers-string-encoding branch May 2, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant