I have a slightly weird issue.  Someone is sending http requests with 
Chinese characters in the URL.  Ok, it's probably just Chinese hackers 
trying something.  But it's causing Django to fall over with a 
UnicodeEncodeError in the response.

I'm thinking this must be a bug in Django as the response is generated by 
Django itself.

I have flatpages turned on, and obviously this url doesn't match anything I 
have in flatpages so it's somewhere in the flatpage not found path.  I also 
have I18N turned on.

I'm running Django version 1.4.8.  Below is the traceback.

Should I just ignore this?

Peter

Traceback (most recent call last):

  File "/home/peter/django-ductedit/django/core/handlers/base.py", line 92, in 
get_response
    response = callback(request, *callback_args, **callback_kwargs)

  File "/home/peter/django-ductedit/django/contrib/flatpages/views.py", line 
23, in flatpage
    return HttpResponseRedirect("%s/" % request.path)

  File "*/home/peter/django-ductedit/django/http/*__init__.py", line 407, in 
__init__
    self['Location'] = redirect_to

  File "*/home/peter/django-ductedit/django/http/*__init__.py", line 320, in 
__setitem__
    header, value = self._convert_to_ascii(header, value)

  File "*/home/peter/django-ductedit/django/http/*__init__.py", line 309, in 
_convert_to_ascii
    value = value.encode('us-ascii')

UnicodeEncodeError: 'ascii' codec can't encode characters in position 10-13: 
ordinal not in range(128), HTTP response headers must be in US-ASCII format


<WSGIRequest
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{},
META:{'DOCUMENT_ROOT': '*/home/peter/public_html/*',
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT': '*/*',
 'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
 'HTTP_HOST': 'www.plandroid.com',
 'HTTP_REFERER': 'http://www.baidu.com',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) 
Gecko/20100101 Firefox/18.0',
 'HTTP_X_FORWARDED_FOR': '183.60.243.188',
 'HTTP_X_FORWARDED_PROTO': 'http',
 'HTTP_X_HOST': 'www.plandroid.com',
 'PATH_INFO': u'*/template/*\u8bf7\u52ff\u5220\u96646kbbs\u6a21\u677f.txt',
 'PATH_TRANSLATED': 
'*/home/peter/public_html//template/*\xe8\xaf\xb7\xe5\x8b\xbf\xe5\x88\xa0\xe9\x99\xa46kbbs\xe6\xa8\xa1\xe6\x9d\xbf.txt',
 'QUERY_STRING': '',
 'REDIRECT_STATUS': '200',
 'REDIRECT_URI': 
'*/django.fcgi/template/*\xe8\xaf\xb7\xe5\x8b\xbf\xe5\x88\xa0\xe9\x99\xa46kbbs\xe6\xa8\xa1\xe6\x9d\xbf.txt',
 'REMOTE_ADDR': '183.60.243.188',
 'REMOTE_PORT': '15624',
 'REQUEST_METHOD': 'GET',
 'REQUEST_URI': 
'*/template/*\xe8\xaf\xb7\xe5\x8b\xbf\xe5\x88\xa0\xe9\x99\xa46kbbs\xe6\xa8\xa1\xe6\x9d\xbf.txt',
 'SCRIPT_FILENAME': '/home/peter/public_html/django.fcgi',
 'SCRIPT_NAME': u'',
 'SERVER_ADDR': '127.0.0.1',
 'SERVER_NAME': 'www.plandroid.com',
 'SERVER_PORT': '62305',
 'SERVER_PROTOCOL': 'HTTP/1.0',
 'SERVER_SOFTWARE': 'lighttpd',
 'wsgi.errors': <flup.server.fcgi_base.TeeOutputStream object at 0xa5cf44c>,
 'wsgi.input': <flup.server.fcgi_base.InputStream object at 0xa5cf22c>,
 'wsgi.multiprocess': True,
 'wsgi.multithread': False,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'http',
 'wsgi.version': (1, 0)}>



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" 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/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7428b624-197e-4e03-b78f-f952ae99bd8a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to