Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fix parsing of names and namespaces with colons #178

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jkugler
Copy link

@jkugler jkugler commented Feb 5, 2025

This attempts to comply with the specification; at minimum brings it in line with what all the other libraries do.

Closes #152
(I think)

See comment at #152 (comment)

This attempts to comply with the specification.

Closes package-url#152
(I think)

See discussion at package-url#152

Signed-off-by: Joshua Kugler <[email protected]>
@jkugler
Copy link
Author

jkugler commented Feb 7, 2025

Howdy @tdruez, could you have a look? Thanks!

@pombredanne
Copy link
Member

@jkugler Thanks. You may want to run make valid to format the code.

Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

Thanks. Do you have actual real package names and namespaces with colons, rather than made up ones?


assert p.type == "nuget"
assert p.namespace is None
assert p.name == "libiconv: character set conversion library"
Copy link
Member

Choose a reason for hiding this comment

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

Is this a real name, seen in the wild? I do not think this would be a valid NuGet name.


def test_colons_in_namespace_are_handled_correctly() -> None:
p = PackageURL.from_string(
"pkg:nuget/an:odd:space/libiconv:%20character%20set%20conversion%[email protected]?package-id=e11a609df352e292"
Copy link
Member

Choose a reason for hiding this comment

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

Could you use actual real life data rather than made up ones? In all cases the colon should be encoded there IMHO.

@@ -459,12 +467,17 @@ def from_string(cls, purl: str) -> Self:
url=remainder, scheme="", allow_fragments=True
)

if scheme or authority:
Copy link
Member

Choose a reason for hiding this comment

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

This would be a serious API change, why do you remove this?

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.

Creation PackageURL objects for invalid PURLs / Possible improper encoding of colons (":") in PURL fields
2 participants