Skip to content

Fix VcpkgComponent purl construction for names containing slashes#1752

Open
JamieMagee wants to merge 2 commits intomainfrom
fix/vcpkg-purl-construction
Open

Fix VcpkgComponent purl construction for names containing slashes#1752
JamieMagee wants to merge 2 commits intomainfrom
fix/vcpkg-purl-construction

Conversation

@JamieMagee
Copy link
Copy Markdown
Member

VcpkgComponent.PackageUrl builds purl strings by interpolating this.Name directly into a string like $"pkg:vcpkg/{this.Name}@{this.Version}". This breaks when vcpkg SPDX entries have names with slashes (e.g. google/brotli, capstone-engine/capstone), because the purl parser treats those slashes as path separators. If the name produces empty segments between slashes, parsing throws MalformedPackageUrlException: The purl namespace has an empty segment between '/' separators.

This switches to the PackageUrl component constructor, which accepts the name as a discrete parameter and handles encoding during serialization.

VcpkgComponent.PackageUrl built purl strings by interpolating
this.Name directly, e.g. $"pkg:vcpkg/{this.Name}@{this.Version}".
Vcpkg SPDX entries can have names like "google/brotli", which the
parser then misinterprets as namespace/name path segments. Names
with consecutive slashes cause an "empty segment" exception.

Use the PackageUrl component constructor instead, which treats
the name as a single component and percent-encodes it properly.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes VcpkgComponent.PackageUrl construction so vcpkg component names containing / are correctly encoded/serialized into a valid Package URL (purl), avoiding parser failures caused by treating / as path separators.

Changes:

  • Replace string-interpolated purl creation with PackageUrl’s structured constructor.
  • Build port_version as an optional qualifiers dictionary when PortVersion > 0.

@JamieMagee JamieMagee requested a review from zhenghao104 March 30, 2026 22:16
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.

3 participants