#28688 closed Bug (fixed)
Unicode slugs are not properly slugified due to javascript limitations
Reported by: | Sævar Öfjörð Magnússon | Owned by: | Sævar Öfjörð Magnússon |
---|---|---|---|
Component: | contrib.admin | Version: | 1.11 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When using unicode slugs, and the slug contains a unicode character and a word from the removelist in urlify.js right after it (e.g. the letter "a"), the unicode character is detected as a word boundary in javascript and the text that matches the removelist is stripped from the slug...
The removelist contains the following words:
var removelist = [
"a", "an", "as", "at", "before", "but", "by", "for", "from", "is",
"in", "into", "like", "of", "off", "on", "onto", "per", "since",
"than", "the", "this", "that", "to", "up", "via", "with"
];
And when I try to slugify this text: "Kaupa miða"
The result becomes: "kaupa-mið"
This can be tested using the following line in console:
URLify("Kaupa miða", 255, true)
(only when urlify.js is loaded, of course)
Change History (7)
comment:1 by , 7 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 7 years ago
comment:3 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 7 years ago
Has patch: | set |
---|
I've created a pull request that implements Claude's suggestion: https://github.com/django/django/pull/9219
comment:5 by , 7 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
The solution could be to check if the string contains any non-ASCII char and simply skip the
removelist
removal, as the language is probably not English in that case.