Fix suggestion caching again for non-ASCII characters

This is why you should test this stuff with random input before rolling
it out. Whoops. URL that caught this problem:

    /opensearch/packages/suggest?q=%D7%A0%D7%9F%D7%92%D7%9F
aka
    /opensearch/packages/suggest?q=נןגן

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2012-05-05 10:19:49 -05:00
parent 86f8efaeb1
commit d4c7a48623

View File

@ -47,7 +47,8 @@ def opensearch_suggest(request):
if search_term == '':
return HttpResponse('', mimetype='application/x-suggestions+json')
cache_key = 'opensearch:packages:' + hashlib.md5(search_term).hexdigest()
cache_key = 'opensearch:packages:' + \
hashlib.md5(search_term.encode('utf-8')).hexdigest()
to_json = cache.get(cache_key, None)
if to_json is None:
names = Package.objects.filter(