-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 Fixed slugs from exceeding db limit #9251
馃悰 Fixed slugs from exceeding db limit #9251
Conversation
@kirrg001 I would like to hear your thought about that. I am not entirely sure, if I might've forgotten a case... I tried for quite a while to implement it in a different way, but take this situation:
We could definitely implement this logic, but IMO this is a but too much for such edge cases and I therefore vote for my solution. |
bbac11a
to
22b3b50
Compare
core/server/models/base/index.js
Outdated
// the slug may never be longer than the allowed limit of 191 chars, but should also | ||
// take the counter into count. We reduce a too long slug to 185 so we're always on the | ||
// safe side, also in terms of checking for existing slugs already. | ||
slug = utils.safeString(base, options).slice(0, 185); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
22b3b50
to
f38d68e
Compare
closes TryGhost#8143 Fixed a potential issue (edge-case), where our generated and validated (in terms of check for existance and add a counter) would return a slug, that will exceed the maximum length of the slug fields (191 chars). This is mostly possible for the post title, which can be 255 chars long and would generate a slug with the same length. This would prevent the user from actually saving a post. I tried first to determine the expected length for a slug that already exists, but decided that the **easier** and simplyfied implementation is to always cut a slug to **185 chars** (+ counter). This makes it easier to find duplicates and includes a possible high number of counts (edge-edge-case). The slug will not be cut down to 185 chars if it's an import.
f38d68e
to
8a07be3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good fix. I can't of a simpler/better solution at the moment. It protects a validation error when the input source (post title, user name) is greater than 191. It does not auto-fix slugs to import. The user has to fix this alone, because a slug can represent an existing url. This is an edge case anyway, because e.g. post titles are usually not so long, same for user names.
closes #8143
Fixed a potential issue (edge-case), where our generated and validated (in terms of check for existance and add a counter) would return a slug, that will exceed the maximum length of the slug fields (191 chars).
This is mostly possible for the post title, which can be 255 chars long and would generate a slug with the same length. This would prevent the user from actually saving a post.
I tried first to determine the expected length for a slug that already exists, but decided that the easier and simplyfied implementation is to always cut a slug to 185 chars (+ counter). This makes it easier to find duplicates and includes a possible high number of counts (edge-edge-case).