#5281 closed (wontfix)
Non unicode GET-data is not allowed?
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | HTTP handling | Version: | dev |
Severity: | Keywords: | unicode GET | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I try access my domain and pass the escaped URL-character for for an example 238 which is %EE
This is of course just an example. My actual implementation has longer values
http://mydomain.com/?info_hash=%EE
In my view I do something like this
def handle_stuff(request): get_data = request.GET.copy() info_hash = get_data["info_hash"] assert(False) # for debugging
The relevant debug info
get_data == <MultiValueDict: {u'info_hash': [u'\ufffd']}>
info_hash == u'\ufffd'
\ufffd is the error character in unicode, so basically standard URL escaped arguments as GET does not work in django as of the unicode branch.
This makes it impossible to interface with any external application that uses this. In my case I was writing a bittorrent tracker, and bittorrent uses non unicode GET-data for it's transmissions. In other words... until this is fixed, using django as a bittorrent tracker is impossible, as well as interfacing django with any other application that uses standard url escaped characters as GET-data.
Change History (5)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
As frej says, setting the encoding to "latin-1" (or "iso-8859-1" if you want to get fancy) will fix this. You'll still the bytes as a Unicode string; do u.encode("iso-8859-1") to get back the original raw string.
Closing this as "wontfix" for now (a "wontfix; workaround provided" would be nice ;-)
follow-up: 4 comment:3 by , 17 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
request.encoding = 'latin-1' not working, request.GET is still <type 'unicode'>
follow-up: 5 comment:4 by , 17 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
Replying to Dorian Grey <imgrey@gmail.com>:
request.encoding = 'latin-1' not working, request.GET is still <type 'unicode'>
Yes, actually read what Fredrik wrote about what you need to do.
comment:5 by , 17 years ago
Replying to ubernostrum:
Replying to Dorian Grey <imgrey@gmail.com>:
request.encoding = 'latin-1' not working, request.GET is still <type 'unicode'>
Yes, actually read what Fredrik wrote about what you need to do.
perhaps curious minds want to know a solution to this problem for the current revision.
- remove slash aftrer 'announce' in urls.py
- request.GETinfo_hash.encode('iso-8859-1').encode('hex')
I was trying to close this myself, but code.djangoproject.com answered "Internal Server Error"
Using request.encoding = 'latin-1' from current svn should fix this.