statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

Slug case insensitivity leads to overwritten content #2440

Open rrelmy opened 5 years ago

rrelmy commented 5 years ago

Describe the bug The check for unique slugs seems to be case sensitive but slugs are not really case sensitive.

To Reproduce Steps to reproduce the behavior:

  1. Create an entry with a slug test
  2. Create an entry with a slug Test. ❗️ No error here
  3. Edit the item with the Test slug. 🐛 Slug is lowercased in the form
  4. Clear cache
  5. Duplicate IDs and the test item is overwritten with the content of Test

Expected behavior Slugs should always be treated case insensitive or it should just work (might be problematic with macOS and Windows).

Environment details (please complete the following information):

jackmcdade commented 4 years ago

Because of the case differences between MacOS and Linux (for example), we do our best to enforce lowercase slugs for maximum compatibility. You would have to explicitly override the slug behavior or create it by hand in the files with uppercase letters to run into this issue. I don't know how best to address it because of the ability to create them by hand, but you can see our attempt in action where we re-lowercase your Test slug.

🤔

rrelmy commented 4 years ago

My main concern ist that this can be reproduced within the CP itself. Without touching files on the file system. We have customers breaking their page because they write into the slug field and the validation does not catch such cases.

Another case where this seems to cause problems is with sites that have uppercase characters in the slugs from older versions.

delz-dev commented 4 years ago

@jackmcdade please please please have a look into it … that's a very odd situation

FrittenKeeZ commented 3 years ago

@jackmcdade we experience the same issue, with a customer not knowing you shouldn't write uppercase letters into the slug. Would it be an issue to actively force the slug to be lowercase before saving/validation? By all means this could be added as a system setting, so existing sites won't break. It'll most likely also require the nginx configuration (or Apache) to match URLs in a case insensitive matter.