mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 06:48:25 +08:00

* FIX: Don't accept accents in slug if generation_method == 'ascii' Fixes bug reported in: - https://meta.discourse.org/t/404-when-trying-to-edit-category-with-accent-in-slug/214762 - https://meta.discourse.org/t/formatting-and-accents-in-urls/215734/5 Assuming `SiteSetting.slug_generation_method == 'ascii'. If the user provides a slug containing non-ascii characters while creating the category, the user will receive a 404 error just after saving the category since the slug will be escaped anyway but Category.find_by_slug_path won't escape the category slug causing the Edit Page of the category to be inaccessible. This commit checks the provided slug and raises an error if the provided slugcontains non-ascii characters ensuring that the provided value is consistent with the site settings. It also changes Category.find_by_slug_path to always escape the slug, since if present, it is escaped anyway in Category.ensure_slug to prevent the 404 in the Edit Category Page in case the user already have some category with a non-ascii slug. * Removed trailing whitespace