S
siddhartag
This is not strictly a python question, but I'm hoping someone here
has come across a similar situation.
I have a django app and I've protected some views with basic
authentication. The user can use any unicode character in the username
and password fields. When this happens, the data is not properly
encoded by the browser before transmission. How can I get the browser
to encode the data as utf-8 before sending it over? Is there some
header I need to send?
This is what I'm doing at the moment.
def getAuthenticateResponse():
response = HttpResponse()
response.status_code = 401
response.headers["WWW-Authenticate"] = 'Basic realm="Realm"'
return response
When I enter character \xf1 as the username which is outside ascii but
within iso-8859-1
Firefox 2.0 sends this as \xf1
IE 7 also sends this as \xf1
But the utf-8 encoding is \xc3\xb1
If I enter character 0BA4 (TAMIL LETTER TA) which is outside
iso-8859-1
Firefox 2 sends this as \xa4 (seems to drop the high byte)
IE 7 sends this as ?
It seems that both browsers are using the iso-8859-1 charset. Is there
any way I can get them to encode the data with utf-8 instead?
Thanks for any help.
has come across a similar situation.
I have a django app and I've protected some views with basic
authentication. The user can use any unicode character in the username
and password fields. When this happens, the data is not properly
encoded by the browser before transmission. How can I get the browser
to encode the data as utf-8 before sending it over? Is there some
header I need to send?
This is what I'm doing at the moment.
def getAuthenticateResponse():
response = HttpResponse()
response.status_code = 401
response.headers["WWW-Authenticate"] = 'Basic realm="Realm"'
return response
When I enter character \xf1 as the username which is outside ascii but
within iso-8859-1
Firefox 2.0 sends this as \xf1
IE 7 also sends this as \xf1
But the utf-8 encoding is \xc3\xb1
If I enter character 0BA4 (TAMIL LETTER TA) which is outside
iso-8859-1
Firefox 2 sends this as \xa4 (seems to drop the high byte)
IE 7 sends this as ?
It seems that both browsers are using the iso-8859-1 charset. Is there
any way I can get them to encode the data with utf-8 instead?
Thanks for any help.