﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
12151	UnicodeEncodeError from django.contrib.comments.views.utils line 41.	Mikkel Høgh	nobody	"I get a lot of server errors like this:

{{{
Traceback (most recent call last):

 File ""/usr/storage/www/wsgiapps/virtualenvs/mikkel.hoegh.org/lib/python2.5/site-packages/django/core/handlers/base.py"", line 92, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File ""/usr/storage/www/wsgiapps/virtualenvs/mikkel.hoegh.org/lib/python2.5/site-packages/django/contrib/comments/views/utils.py"", line 41, in confirmed
   comment = comments.get_model().objects.get(pk=request.GET['c'])

 File ""/usr/storage/www/wsgiapps/virtualenvs/mikkel.hoegh.org/lib/python2.5/site-packages/django/db/models/manager.py"", line 120, in get
   return self.get_query_set().get(*args, **kwargs)

 File ""/usr/storage/www/wsgiapps/virtualenvs/mikkel.hoegh.org/lib/python2.5/site-packages/django/db/models/query.py"", line 299, in get
   clone = self.filter(*args, **kwargs)

 File ""/usr/storage/www/wsgiapps/virtualenvs/mikkel.hoegh.org/lib/python2.5/site-packages/django/db/models/query.py"", line 498, in filter
   return self._filter_or_exclude(False, *args, **kwargs)

 File ""/usr/storage/www/wsgiapps/virtualenvs/mikkel.hoegh.org/lib/python2.5/site-packages/django/db/models/query.py"", line 516, in _filter_or_exclude
   clone.query.add_q(Q(*args, **kwargs))

 File ""/usr/storage/www/wsgiapps/virtualenvs/mikkel.hoegh.org/lib/python2.5/site-packages/django/db/models/sql/query.py"", line 1675, in add_q
   can_reuse=used_aliases)

 File ""/usr/storage/www/wsgiapps/virtualenvs/mikkel.hoegh.org/lib/python2.5/site-packages/django/db/models/sql/query.py"", line 1614, in add_filter
   connector)

 File ""/usr/storage/www/wsgiapps/virtualenvs/mikkel.hoegh.org/lib/python2.5/site-packages/django/db/models/sql/where.py"", line 56, in add
   obj, params = obj.process(lookup_type, value)

 File ""/usr/storage/www/wsgiapps/virtualenvs/mikkel.hoegh.org/lib/python2.5/site-packages/django/db/models/sql/where.py"", line 269, in process
   params = self.field.get_db_prep_lookup(lookup_type, value)

 File ""/usr/storage/www/wsgiapps/virtualenvs/mikkel.hoegh.org/lib/python2.5/site-packages/django/db/models/fields/__init__.py"", line 210, in get_db_prep_lookup
   return [self.get_db_prep_value(value)]

 File ""/usr/storage/www/wsgiapps/virtualenvs/mikkel.hoegh.org/lib/python2.5/site-packages/django/db/models/fields/__init__.py"", line 361, in get_db_prep_value
   return int(value)

UnicodeEncodeError: 'decimal' codec can't encode character u'\ufffd' in position 46: invalid decimal Unicode string
}}}

The cause of this problem is the request containing junk data:

{{{
GET:<QueryDict: {u'c': [u'4549                   \t              Result: \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd']}>,
HTTP_REFERER': 'http://mikkel.hoegh.org/comments/posted/?c=4549+++++++++++++++++++%09++++++++++++++Result:+%ED%E5+%ED%E0%F8%EB%EE%F1%FC+%F4%EE%F0%EC%FB+%E4%EB%FF+%EE%F2%EF%F0%E0%E2%EA%E8;',
'QUERY_STRING': 'c=4549+++++++++++++++++++%09++++++++++++++Result:+%ED%E5+%ED%E0%F8%EB%EE%F1%FC+%F4%EE%F0%EC%FB+%E4%EB%FF+%EE%F2%EF%F0%E0%E2%EA%E8;',
'REQUEST_URI': '/comments/posted/?c=4549+++++++++++++++++++%09++++++++++++++Result:+%ED%E5+%ED%E0%F8%EB%EE%F1%FC+%F4%EE%F0%EC%FB+%E4%EB%FF+%EE%F2%EF%F0%E0%E2%EA%E8;',
}}}

I'm not quite sure what whoever making these request is trying to accomplish, but the server error should probably be avoidable with a bit more validation of the request parameters. Any ideas?

"		closed	contrib.comments	dev		fixed		Mikkel Høgh	Accepted	1	0	0	1	0	0
