statamic / v2-hub

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

Slug with umlauts break the page #2398

Closed rrelmy closed 5 years ago

rrelmy commented 5 years ago

Describe the bug Using umlauts like äöüèéà… in entry slugs (most likely pages too) breaks the entire page. Our customers like to use umlauts in slugs and continuously break the page with it.

InvalidEntryTypeException in Entry.php line 201:
Entry date not present in a date-based entry: [collections/summer-news/sommersaisonstüüürt.md]

The nasty thing it is working until you clear the cache and the data is reloaded from disk.

Related: #824

Proposed solution 😏 The regexes in OrderParser->get(Entry|Page)Order are causing the issue. They try to catch the rest of the filename with \w, \w does not include characters like umlauts.

My proposal would be to replace the [\w_-]+ pattern with [^\/]+ to match every possible character. I tested this change with a site and could not find any problems so far.

To Reproduce Steps to reproduce the behavior:

  1. CP: Add a umlaut äöü directly to the slug of an entry
  2. Save, everything works until cache is cleared
  3. Clear cache
  4. See error

Expected behavior The cp should disallow using such characters or it should work.

Environment details (please complete the following information):

jesseleite commented 5 years ago

Opted for a slightly different approach, by conventionally wrapping slugs with Laravel's Str::slug($slug) to ensure that umlauts and similar characters don't make it through filenames, URLs, etc. Should be in next release though!