Encode "+" as "%2B" since "+" is a valid SemVer character.#17
Merged
wagoodman merged 2 commits intoanchore:masterfrom Mar 12, 2024
Merged
Encode "+" as "%2B" since "+" is a valid SemVer character.#17wagoodman merged 2 commits intoanchore:masterfrom
wagoodman merged 2 commits intoanchore:masterfrom
Conversation
tiegz
commented
Jan 23, 2024
packageurl.go
Outdated
Author
There was a problem hiding this comment.
note that url.QueryEscape will encode +, but that method was replaced with PathEscape in #1
tiegz
commented
Jan 23, 2024
packageurl_test.go
Outdated
Author
There was a problem hiding this comment.
before the fix in this PR, this test would fail as:
packageurl_test.go:389: expected pkg:type/name/space/name@versio%20n%2Bbeta?key=value#sub/path to parse as pkg:type/name/space/name@versio%20n%2Bbeta?key=value#sub/path but got pkg:type/name/space/name@versio%20n+beta?key=value#sub/path
Author
|
another example where not-escaping |
|
Has the anchor community looked into merging this code? |
Signed-off-by: Tieg Zaharia <tieg@tidelift.com>
b9d97ca to
9bd4a32
Compare
|
I'll work on getting CI passing -- thanks for the fix! 🙌 |
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
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.
Currently this library is generating PURLs like
pkg:golang/github.com/azure/azure-sdk-for-go@v56.3.0+incompatible.The PURL spec says that versions should be a "percent-encoded string", and while the
+character is fine to use while escapingfor application/x-www-form-urlencoded content, the original RFC3986 spec for general URIs does not mention using+to escape.I think it's preferable to escape
+because downstream parsers of the URL will likely unescape the+as, resulting in invalid PURL versions as inpkg:golang/github.com/azure/azure-sdk-for-go@v56.3.0 incompatible.There's a good analysis of this problem in package-url/purl-spec#261 as well.