mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-03 06:36:23 +08:00
Localized tag names were never run through `DiscourseTagging.clean_tag`, unlike regular tag names. A localized name like `mijn-naam" (123)` would be stored and rendered as-is, breaking body classes (`tag-mijn-naam" (123)`) and tag display under topic titles. This PR adds a `before_validation` callback on `TagLocalization` that cleans names with `DiscourseTagging.clean_tag`. This covers all three entry points `TagLocalizationCreator`, `TagLocalizationUpdater`, and `TagSettingsUpdater` at the model. Includes a post-migration that cleans existing dirty localization names. The migration only fetches rows that actually violate, names with special characters from `TAGS_FILTER_REGEXP`, uppercase when `force_lowercase_tags` is on, or names exceeding `max_tag_length`. The actual cleaning still uses `DiscourseTagging.clean_tag` so it respects site settings. We try to minimize calling application code in migrations, but this is quite controlled. Related: https://meta.discourse.org/t/localized-tags-are-not-slugified/398105 |
||
|---|---|---|
| .. | ||
| 20260311064518_clean_existing_tag_localization_names_spec.rb | ||