API Redirects properly handle unicode.

This commit is contained in:
Dave Dash 2010-03-16 10:52:28 -07:00
Родитель bf2507feab
Коммит b4ad13451d
2 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -1,3 +1,5 @@
# -*- coding: utf8 -*-
import math
from django.conf import settings
@ -34,6 +36,11 @@ class No500Errors(TestCase):
# is good. We just don't want 500 errors.
assert response.status_code != 500, "We recieved a 500 error, wtf?"
def test_utf_redirect(self):
"""Test that urls with unicode redirect propperly."""
response = make_call(u'search/ツールバー', version=1.5)
assert response.status_code != 500, "Unicode failed to redirect."
class ControlCharacterTest(TestCase):
"""This test is to assure we aren't showing control characters."""

Просмотреть файл

@ -14,6 +14,7 @@ from l10n import ugettext as _, ugettext_lazy
import jingo
import amo
from amo.urlresolvers import get_url_prefix
import api
from addons.models import Addon
from search.client import Client as SearchClient, SearchError
@ -214,5 +215,8 @@ def redirect_view(request, url):
"""
Redirect all requests that come here to an API call with a view parameter.
"""
return HttpResponsePermanentRedirect('/api/%.1f/%s' %
(api.CURRENT_VERSION, url))
dest = '/api/%.1f/%s' % (api.CURRENT_VERSION,
urllib.quote(url.encode('utf-8')))
dest = get_url_prefix().fix(dest)
return HttpResponsePermanentRedirect(dest)