Skip to content

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

@jkowalleck

Description

@jkowalleck

while I was working on #578 - which is completely based on "Rules for each purl component", i found some cases that are not properly parsable with the current specced "How to parse a purl string in its components"

non-canonical test case, valid according to spec :

  • pkg://////foo-type/////bar-namespace////bazz-name/////@version
    • multiple slashes after the ":" -
      followed by one or more slash '/' characters, such as 'pkg://', and MUST
      ignore and remove all such '/' characters.
    • multiple slashes leading and trailing the namespace -
      - All leading and trailing slashes '/' are not significant and SHOULD be
      stripped in the canonical form. They are not part of the ``namespace``.
    • multiple slashes leading and trailing the name -
      - All leading and trailing slashes '/' are not significant and SHOULD be
      stripped in the canonical form. They are not part of the ``name``.
  • ... add other cases here ...

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/trailing 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. split remainder once from right on /
    • remainder: ////bar-namespace////bazz-name////
    • name: `` (empty string)

looks like the following instructions is placed at the wrong position:

  • Strip all leading and trailing '/' characters (e.g., '/', '//', '///' and
    so on) from the remainder

instead, at this position, it would be enough to strip leading slashes,
and in addition, the strip of leading and trailing slashes is needed for name/namespace

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions