Skip to content

fix: parse PURL for name/namespace#583

Merged
pombredanne merged 6 commits intopackage-url:mainfrom
jkowalleck:fix/spec-parse-order
Aug 15, 2025
Merged

fix: parse PURL for name/namespace#583
pombredanne merged 6 commits intopackage-url:mainfrom
jkowalleck:fix/spec-parse-order

Conversation

@jkowalleck
Copy link
Member

@jkowalleck jkowalleck commented Aug 7, 2025


using the previously broken example from the issue #582

parsing pkg://////foo-type/////bar-namespace////bazz-name/////@version

  1. split once from right #
    • no subpath
    • remainder: pkg://////foo-type/////bar-namespace////bazz-name/////@version
  2. split once from right ?
    • no qualifiers
    • remainder: pkg://////foo-type/////bar-namespace////bazz-name/////@version
  3. split once left on :
    • schema: pkg
    • remainder //////foo-type/////bar-namespace////bazz-name/////@version
  4. strip leading slashes
    • result: foo-type/////bar-namespace////bazz-name/////@version
  5. split once left of /
    • type: foo-type
    • remainder: ////bar-namespace////bazz-name/////@version
  6. split once from right on @
    • version: version
    • remainder: ////bar-namespace////bazz-name/////
  7. strip trialing slashes
    • result: ////bar-namespace////bazz-name
  8. split once right on /
    • remainder: ////bar-namespace///
    • name: bazz-name
  9. split on / and discard empty segments ...
    • namespace: bar-namespace

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
@jkowalleck jkowalleck requested review from a team, johnmhoran and pombredanne August 7, 2025 09:51
@jkowalleck jkowalleck added the bug label Aug 7, 2025
- This is the ``version``

- Split the ``remainder`` once from right on '/'
- Strip all leading and trailing '/' characters (e.g., '/', '//', '///' and
Copy link
Member Author

Choose a reason for hiding this comment

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

this was the most relevant - the missing - part

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
ppkarwasz
ppkarwasz previously approved these changes Aug 7, 2025
Copy link
Contributor

@ppkarwasz ppkarwasz left a comment

Choose a reason for hiding this comment

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

Great job! 💯

@mjherzog
Copy link
Member

@jkowalleck @ppkarwasz We have just in the last hour merged #589 to split PURL-SPECIFICATION.rst into markdown files in the new /docs directory. This was needed to prepare for publishing the Ecma Standard document and later for documentation on the packageurl.org website.
We will push an update to PURL-SPECIFICATION.rst by tomorrow to redirect to the corresponding /docs files.
I apologize for the extra work, but please re-apply these changes to /docs/how-to-parse.md. We did not change the content of the "How to parse a purl string into its components" content except for markdown formatting.

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
@jkowalleck
Copy link
Member Author

please re-apply these changes to /docs/how-to-parse.md

done.

also reverted changes on PURL-SPECIFICATION.rst.

will do so again, if needed, after

We will push an update to PURL-SPECIFICATION.rst by tomorrow to redirect to the corresponding /docs files.

sure thing. will update this PR again, to prevent any merge conflicts - if needed :)

@mjherzog
Copy link
Member

@jkowalleck Thank you

Copy link
Member

@mjherzog mjherzog left a comment

Choose a reason for hiding this comment

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

Agree to merge and update tests following

Copy link
Member

@johnmhoran johnmhoran left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

All good. Thanks!

@pombredanne pombredanne merged commit fdbdf5d into package-url:main Aug 15, 2025
giterlizzi added a commit to giterlizzi/perl-URI-PackageURL that referenced this pull request Aug 15, 2025
- Improved 'name' and 'namespace' parsing (package-url/purl-spec#582 - package-url/purl-spec#583)
- Improved t/99-*.t tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

purl parsing for name /namespace is faulty, according to spec

5 participants