From 690c2c3b29419d08763284eec5c6f4d571dce345 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Wed, 3 Jun 2015 17:42:25 +0200 Subject: [PATCH] some encode stuff --- cas_server/utils.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cas_server/utils.py b/cas_server/utils.py index 4a27276..25a98a8 100644 --- a/cas_server/utils.py +++ b/cas_server/utils.py @@ -1,3 +1,4 @@ +# ⁻*- coding: utf-8 -*- # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License version 3 for @@ -35,11 +36,20 @@ def redirect_params(url_name, params=None): def update_url(url, params): """update params in the `url` query string""" + if isinstance(url, unicode): + url = url.encode('utf-8') + for key, value in params.items(): + if isinstance(key, unicode): + del params[key] + key = key.encode('utf-8') + if isinstance(value, unicode): + value = value.encode('utf-8') + params[key] = value url_parts = list(urlparse.urlparse(url)) query = dict(urlparse.parse_qsl(url_parts[4])) query.update(params) url_parts[4] = urllib.urlencode(query) - return urlparse.urlunparse(url_parts) + return urlparse.urlunparse(url_parts).decode('utf-8') def unpack_nested_exception(error): """If exception are stacked, return the first one"""