Skip to content

Fix VcpkgComponent purl construction for names containing slashes#1752

Merged
JamieMagee merged 2 commits into
mainfrom
fix/vcpkg-purl-construction
Mar 31, 2026
Merged

Fix VcpkgComponent purl construction for names containing slashes#1752
JamieMagee merged 2 commits into
mainfrom
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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
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.
@JamieMagee JamieMagee force-pushed the fix/vcpkg-purl-construction branch from 6617a56 to 37b76b6 Compare March 31, 2026 16:37
@JamieMagee JamieMagee enabled auto-merge (squash) March 31, 2026 16:37
@JamieMagee JamieMagee merged commit 8f1a8b6 into main Mar 31, 2026
22 of 23 checks passed
@JamieMagee JamieMagee deleted the fix/vcpkg-purl-construction branch March 31, 2026 16:44
@codecov

codecov Bot commented Mar 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.0%. Comparing base (7fb976c) to head (37b76b6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #1752   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Apr 1, 2026

Copy link
Copy Markdown

👋 Hi! It looks like you modified some files in the Detectors folder.
You may need to bump the detector versions if any of the following scenarios apply:

  • The detector detects more or fewer components than before
  • The detector generates different parent/child graph relationships than before
  • The detector generates different devDependencies values than before

If none of the above scenarios apply, feel free to ignore this comment 🙂

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