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

Invalid purl: version must be percent-encoded #64

Open
kennylam91 opened this issue Dec 20, 2023 · 1 comment
Open

Invalid purl: version must be percent-encoded #64

kennylam91 opened this issue Dec 20, 2023 · 1 comment

Comments

@kennylam91
Copy link

Hi, I encounter this error: Invalid purl: version must be percent-encoded when parse the purl pkg:npm/@vue/vue-loader-v15@15.11.1 with method PackageURL.fromString().
This purl was validated successfully by other library mvn:packageurl-java@1.4.1 in the backend.

When I look into the code of packageurl-js, I see this:

if (p.includes('@')) {
    let f = p.indexOf('@'),
      u = p.substring(f + 1)
    a = decodeURIComponent(u)
    let y = encodeURIComponent(a).replace(/%3A/g, ':').replace(/%2B/g, '+')
    if (u !== y)
      throw new Error('Invalid purl: version must be percent-encoded')
    i = p.substring(0, f)
}

I think it could have an issue because method indexOf() return the first matched index, but in this case pkg:npm/@vue/vue-loader-v15@15.11.1, it has another @ so f+1 is not the start of version substring.

@steven-esser
Copy link
Collaborator

@kennylam91 Thanks for the bug report, will take a look.

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

No branches or pull requests

2 participants