Hi!

I have a problem with IE sending headers encoded as UTF-8 instead of URL 
encoded ASCII(?).

the HTTP_REFERER key in environ is for FireFox:
http://www.example.com/f%C3%B6k.html

but for IE:
http://www.example.com/fök.html  (encoded as utf-8)

This causes problems as soon as we want to use this in templates as this 
will raise a UnicodeError 
as soon as the request.referrer is used anywhere in a template. (By default 
Python tries to decode string as ascii)

Has anyone managed to fix this gracefully?

My best idea how to fix this is a middleware something like this:

try:
  environ['HTTP_REFERER'].decode('ascii')
except UnicodeError:
  environ['HTTP_REFERER'] = get_host(environ['HTTP_REFERER']) + 
urllib.quote( get_path(environ['HTTP_REFERER']) )

But this seems a bit weird/overkill, what do you guys think?

/JT

-- 
You received this message because you are subscribed to the Google Groups 
"pocoo-libs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pocoo-libs.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to