From f487fbb298b5af27587af747f4392ed58fc3e0d1 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 6 Feb 2014 11:39:29 +0100 Subject: [PATCH] [FIX] website: urljoin from urlparse cannot handle unicode. Therefore, We decode before passing the arg to urljoin then we (re-)encode the result bzr revid: dle@openerp.com-20140206103929-oe289oilz08n1msk --- addons/website/models/website.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/website/models/website.py b/addons/website/models/website.py index e3c683861f9..a3d7e154678 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -36,12 +36,18 @@ def keep_query(*args, **kw): return werkzeug.urls.url_encode(params) def url_for(path_or_uri, lang=None): + if isinstance(path_or_uri, unicode): + path_or_uri = path_or_uri.encode('utf-8') + current_path = request.httprequest.path + if isinstance(current_path, unicode): + current_path = current_path.encode('utf-8') location = path_or_uri.strip() force_lang = lang is not None url = urlparse.urlparse(location) if request and not url.netloc and not url.scheme and (url.path or force_lang): - location = urlparse.urljoin(request.httprequest.path, location) + location = urlparse.urljoin(current_path, location) + lang = lang or request.context.get('lang') langs = [lg[0] for lg in request.website.get_languages()] @@ -59,7 +65,7 @@ def url_for(path_or_uri, lang=None): ps.insert(1, lang) location = '/'.join(ps) - return location + return location.decode('utf-8') def is_multilang_url(path, langs=None): if not langs: