# Category slug containing Unicode characters results in redirect loop

**URL:** https://meta.discourse.org/t/category-slug-containing-unicode-characters-results-in-redirect-loop/169788
**Category:** Bug
**Created:** [November 11, 2020, 12:36am UTC](https://meta.discourse.org/t/category-slug-containing-unicode-characters-results-in-redirect-loop/169788 "2020-11-11T00:36:17Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![dan-barbulescu](https://avatars.discourse-cdn.com/v4/letter/d/258eb7/32.png) [@dan-barbulescu](https://meta.discourse.org/u/dan-barbulescu)
#### Post date: [November 11, 2020, 12:36am UTC](https://meta.discourse.org/t/category-slug-containing-unicode-characters-results-in-redirect-loop/169788/1 "2020-11-11T00:36:17Z")

</div>

I have enabled (some) Unicode characters in usernames and everything works as expected.

When I tried using Unicode characters in a category slug, it converted it to percent encoding and allowed me to save the changes, but I was no longer able to access the category topic list because I’d get `ERR_TOO_MANY_REDIRECTS`.

I seem to have fixed it using the Rails console:

> Category.find(_id_).update(slug: ‘slug-without-unicode’)

This isn’t a show-stopper, but it can break things, so I’d suggest it should either be fully implemented or guarded against.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [November 11, 2020, 1:21am UTC](https://meta.discourse.org/t/category-slug-containing-unicode-characters-results-in-redirect-loop/169788/2 "2020-11-11T01:21:12Z")

</div>

> [@dan-barbulescu](#):
>
> This isn’t a show-stopper, but it can break things, so I’d suggest it should either be fully implemented or guarded against.

Some work has been done on this in the past, but I do not think the issue you ran into has been addressed. What I think happened is that you have the `slug generation method` set to ‘ascii’ and you directly entered a category slug that has non-ascii characters in it. I can reproduce that issue on my site with the `slug generation method` set to ‘ascii’ and the following text (`yetersizliği`) entered directly into the Category Slug field:

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/7/b71585e7bb7b5e5bfc81a90cafd91f989988185a.png)

After saving the category:

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/2/c2cc9a5666b5098923aefcd837d70cddc04d9f8a.png)

Attempting to load that category list then fails.

If I don’t enter anything into the Category Slug field, DIscourse will create the slug correctly when the `slug generation method` is set to ‘ascii’.

With the `slug generation method` is set to ‘encoded’, Discourse handles creating the slug correctly both when I leave the Category Slug input empty and if I directly enter the non-ascii slug into the input.

So it seems that the issue is that when the `slug generation method` is set to ‘ascii’, non-ascii slugs can still be entered into the Category Slug field. This causes a redirect issue that can only be fixed from the Rails console.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [November 11, 2020, 2:04am UTC](https://meta.discourse.org/t/category-slug-containing-unicode-characters-results-in-redirect-loop/169788/3 "2020-11-11T02:04:57Z")

</div>

So what we need is a model validation on save here right?

I can take it.

---

<div class="post-metadata">

### Author: ![dan-barbulescu](https://avatars.discourse-cdn.com/v4/letter/d/258eb7/32.png) [@dan-barbulescu](https://meta.discourse.org/u/dan-barbulescu)
#### Post date: [November 11, 2020, 2:28am UTC](https://meta.discourse.org/t/category-slug-containing-unicode-characters-results-in-redirect-loop/169788/5 "2020-11-11T02:28:52Z")

</div>

> [@simon](#):
>
> What I think happened is that you have the `slug generation method` set to ‘ascii’ and you directly entered a category slug that has non-ascii characters in it.

That’s exactly what I did, I was editing a category that had been previously created—both its name and slug. I didn’t know about the `slug generation method` setting, and, even though I later found it to be set to `ascii`, the slug was encoded anyway.

This kind of coercion might make sense, but only if the encoded slug can be later recognized, ignoring the setting in a similar way.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [November 12, 2020, 7:53pm UTC](https://meta.discourse.org/t/category-slug-containing-unicode-characters-results-in-redirect-loop/169788/6 "2020-11-12T19:53:03Z")

</div>

This should fix it

[https://github.com/discourse/discourse/pull/11277](https://github.com/discourse/discourse/pull/11277)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [December 13, 2020, 11:32pm UTC](https://meta.discourse.org/t/category-slug-containing-unicode-characters-results-in-redirect-loop/169788/7 "2020-12-13T23:32:47Z")

</div>

3 posts were split to a new topic: [Unicode username results in error loading profile page](https://meta.discourse.org/t/unicode-username-results-in-error-loading-profile-page/173182)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [January 15, 2021, 5:33pm UTC](https://meta.discourse.org/t/category-slug-containing-unicode-characters-results-in-redirect-loop/169788/9 "2021-01-15T17:33:23Z")

</div>

The above PR was merged 🎉

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [January 15, 2021, 5:33pm UTC](https://meta.discourse.org/t/category-slug-containing-unicode-characters-results-in-redirect-loop/169788/10 "2021-01-15T17:33:27Z")

</div>


