Code

Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#5281 closed (wontfix)

Non unicode GET-data is not allowed?

Reported by: bjorn.kempen@… Owned by: nobody
Component: HTTP handling Version: master
Severity: Keywords: unicode GET
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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.

Attachments (0)

Change History (5)

comment:1 Changed 7 years ago by frej

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

comment:2 Changed 7 years ago by Fredrik Lundh <fredrik@…>

  • Resolution set to wontfix
  • Status changed from new to 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 ;-)

comment:3 follow-up: Changed 6 years ago by Dorian Grey <imgrey@…>

  • Resolution wontfix deleted
  • Status changed from closed to reopened

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

comment:4 in reply to: ↑ 3 ; follow-up: Changed 6 years ago by ubernostrum

  • Resolution set to wontfix
  • Status changed from reopened to 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 in reply to: ↑ 4 Changed 6 years ago by Dorian Grey <imgrey@…>

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"

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.