Opened 17 years ago

Closed 16 years ago

Last modified 16 years ago

#5281 closed (wontfix)

Non unicode GET-data is not allowed?

Reported by: bjorn.kempen@… 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 frej, 17 years ago

Using request.encoding = 'latin-1' from current svn should fix this.

comment:2 by Fredrik Lundh <fredrik@…>, 17 years ago

Resolution: wontfix
Status: newclosed

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 ;-)

comment:3 by Dorian Grey <imgrey@…>, 16 years ago

Resolution: wontfix
Status: closedreopened

request.encoding = 'latin-1' not working, request.GET is still <type 'unicode'>

in reply to:  3 ; comment:4 by James Bennett, 16 years ago

Resolution: wontfix
Status: reopenedclosed

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.

in reply to:  4 comment:5 by Dorian Grey <imgrey@…>, 16 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.

  1. remove slash aftrer 'announce' in urls.py
  2. request.GETinfo_hash.encode('iso-8859-1').encode('hex')

I was trying to close this myself, but code.djangoproject.com answered "Internal Server Error"

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