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

🐛 fixed the slug generator to not allow single character slugs #21261

Closed
wants to merge 4 commits into from

Conversation

cathysarisky
Copy link
Contributor

@cathysarisky cathysarisky commented Oct 9, 2024

closes #20133 and masks the effects of TryGhost/NQL#20

It is currently possible to create a user, tag, post, etc with a single character slug.
(It is far too easy to do this with users, if your users have names like C. Ann Smythe.)

Single character slugs break things. They break displaying the posts of a user with a single character slug, and displaying posts with a single-character tag slug, and so on.

Since fixing the underlying NQL parser glitch isn't an easy option, this patch tweaks the logic for generating slugs by
(1) not truncating user names during user creating before the second character (so C. Ann Smythe becomes c-ann instead of c)
(2) checking late in the process for single character slugs, and changing them to baseName-slug, such that a post with title 'q' becomes 'post-q', and a user requesting a change to their slug to the slug 't' will be 'user-t' instead, or if they're new and we are generating the slug from their name, they'll be user-t if their whole name is 'T', or t-lastname if there's more to work with.

The one spot where I feel like this could be improved is user-requested slugs from the profile, where slug generation happens on clicking save (I think), rather than the field updating live like the it does with post slugs.

@9larsons
Copy link
Contributor

Could you elaborate a bit on what troubles are caused w/in NQL?

@cathysarisky
Copy link
Contributor Author

Could you elaborate a bit on what troubles are caused w/in NQL?

Yep. Filtering with single character strings doesn't work. See #20133 and TryGhost/NQL#20

@ErisDS
Copy link
Member

ErisDS commented Oct 15, 2024

Honestly, I thought we fixed the NQL issue ages ago 😢
Wondering if it regressed or if I have lost the actual plot 🤔

@cathysarisky
Copy link
Contributor Author

cathysarisky commented Oct 15, 2024 via email

@9larsons
Copy link
Contributor

I've just merged TryGhost/NQL@07cc8c1 so I'll bump NQL and make sure that all passed ok.

Going to close this one out 🙂.

@9larsons 9larsons closed this Oct 17, 2024
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.

Author slug with one letter causes failed filter
3 participants