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

reject sqids with many numbers #9

Conversation

rktjump
Copy link

@rktjump rktjump commented Nov 11, 2024

This pull request makes django-sqids reject sqid fields with more than one number in it.

This actually happened to me in production. A random character sequence turned out to be a proper sqid, just with two numbers instead of one. (For example, [1, 42] instead of just [1].)
Because django-sqids only looks at first number, an url with such sqid is actually valid, and in my case resolved to a page with real existing model instance.
That url then got indexed by a popular search engine, which got confused because the canonical url wouldn't match, messing up the SEO stuff.

@julianwachholz
Copy link
Owner

Great find, thank you for this! Indeed for the primary key of an instance we never want more than one number returned.

@julianwachholz julianwachholz merged commit a8aa1d4 into julianwachholz:main Nov 12, 2024
13 checks passed
@julianwachholz julianwachholz added the bug Something isn't working label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants