#30892: slugify() doesn't return a valid slug for "İ".
-------------------------------------+-------------------------------------
Reporter: Luis Nell | Owner:
| Christoffer Sjöbergsson
Type: Bug | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Christoffer Sjöbergsson):
* has_patch: 0 => 1
Comment:
This far there are two different but similar fixes. Fix 1 proposed by Luis
Nell to move the `lower()` operation to before the re.sub like so
{{{#!python
re.sub(r'[^\w\s-]', '', value.lower()).strip()
}}}
The second idea that I proposed were to move the `lower()` operation
before the how if statement and as such place it before the normalization
operation.
I have now done some further testing and my conclusion is that the first
alternative seems to be bests. Both solutions does fix the bug in question
but the second
solution seems to change the output of strings quite a bit when they
contain certain characters. I would assume that it would be better to fix
the bug without altering the behavior too much from the original behavior.
As far as I can tell the first solution does not alter the output for any
other characters but the intended one.
I have created a pull request. It can be found here
[https://github.com/django/django/pull/12237]
That one have a quite small set of tests that should cover most of the
issues I have found.
I have also created a separate branch in my fork of Django with an
extended set of tests that I have made to test a large number of
characters in a systematic way. They are however both slow and quite ugly
so I will not include them in the pull request. You can check them out
here
[https://github.com/Sjbrgsn/django/blob/ticket_30892_extended_tests/tests/model_fields/test_slugfield.py]
So right now I have not been able to find any unwanted behavior with the
solution in the patch. But there might very well be some so feel free to
test and report any issues.
--
Ticket URL: <https://code.djangoproject.com/ticket/30892#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.c90c7fc714420404f42fcd5d05702860%40djangoproject.com.