Opened 8 years ago

Closed 8 years ago

Last modified 16 months ago

#5090 closed Uncategorized (wontfix)

Url patterns are case-sensitive.

Reported by: Alex Nickolaenkov <nickolaenkov@…> Owned by: mtredinnick
Component: HTTP handling Version: master
Severity: Normal Keywords: url handling
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

the following urls are treated as different:
http://127.0.0.1:8000/now/PLUS4HOURS/[[BR]]
and
http://127.0.0.1:8000/now/plus4hours/[[BR]]


urls are taken from the tutorial. To reproduce just change the case of letters. I think this is a MAJOR but because it reproduces in the production.

Take a look:

http://www.coastalbeat.com/news/2007/jul/30/simpsons/ 200 OK

http://www.coastalbeat.com/news/2007/jul/30/Simpsons/ BAD 404 response


FIX:
objects RegexURLPattern, RegexURLResolver have the same piece of code:
self.regex = re.compile(regex, re.UNICODE)
change at least to
self.regex = re.compile(regex, re.UNICODE | re.IGNORECASE)
and the things are done.


Attachments (1)

urlresolvers.py (12.1 KB) - added by Alex Nickolaenkov <nickolaenkov@…> 8 years ago.
simplies patch

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by Alex Nickolaenkov <nickolaenkov@…>

simplies patch

comment:1 Changed 8 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

Different case URLs should be treated as such because they aren't the same. Feel free to bring this up in the Django Dev group, but I really don't think you're going to win this one.

In the future, provide a diff patch as opposed to just attaching your version of the modified file.

comment:2 follow-up: Changed 8 years ago by Alex Nickolaenkov <nickolaenkov@…>

  • Resolution wontfix deleted
  • Status changed from closed to reopened

Brought to Dev group.

The following letter:

Hello guys,

Django is positioned as a tool for perfectionists. So there is a
few questions which are very valuable for guys making the best web-sites:

  • Case-sensitive urls. Take a look: http://www.coastalbeat.com/news/2007/jul/30/simpsons/ http://www.coastalbeat.com/news/2007/jul/30/Simpsons/ The urls are pretty same. But the second one causes 404 Response. While typing the second url the user tries to access typing its address and types "Simpsons" instead of "simpsons". In terms of nix-like systems this is a major difference.. But nix systems are designed for professionals, not for my 50 year old aunt browsing the Internet. She knows nothing about different interpretation of letters in the computer world. When I was watching google video about django (by Jacob) I though: Hey, some cool guys finally understood that crappy urls are bad. Let's do some more work and make urls usable and accessible. Furthermore if user sees 404 error instead of page one was looking for, that's not his loss, that is a loss of the site. What do you think?

I've posted corresponding ticket.
http://code.djangoproject.com/ticket/5090
Now it is closed as "won't fix". At least the resolution should be
changed to "By Design" if you guys don't like sites built on django
being convenient.

Here is an example of case-insensitive urls. They rock:
http://www.askeri.ru/PUBLISH/
http://www.askeri.ru/publish/

  • What do you think about including Web Typography support as a built-in django feature?

--
Best regards,

Alex mailto:nikolaenkov@…

comment:3 Changed 8 years ago by jacob

  • Resolution set to wontfix
  • Status changed from reopened to closed

What SmileyChris said.

comment:4 Changed 8 years ago by anonymous

You can handle case-(in)sensitivity in your views. Conversely, if URLs were case-insensitive by default, it would be hard or impossible to change them into case-sensitive within views, so it would be a net loss of functionality.

comment:5 Changed 5 years ago by Velmont

You can just use the regex to check without case sensitivity.

comment:6 in reply to: ↑ 2 Changed 16 months ago by anonymous

  • Easy pickings unset
  • Severity set to Normal
  • Type set to Uncategorized
  • UI/UX unset

Replying to Alex Nickolaenkov <nickolaenkov@…>:

Actually, your example is wrong, since the URL http://www.gonaples.com/news/2007/Jul/30/simpsons/ will work correctly. Suppose they are using Django, they would be using case insensitive regexes ((?i) prefix, per 5), but their object lookup query is not case-insensitive. They would have to use Article.objects.get(slug__iexact="Simpsons") in addition to the case-insensitive regex for the whole mechanism to work.

Note: See TracTickets for help on using tickets.
Back to Top