[FIX] *: replace urllib calls by werkzeug calls, as werkzeug handles utf-8 encoding while urllib doesnt
bzr revid: dle@openerp.com-20140130112408-8pdju26jnkyxvlw2
This commit is contained in:
parent
e974e1fbea
commit
18532330d4
|
@ -23,7 +23,6 @@ import logging
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import getpass
|
import getpass
|
||||||
import urllib
|
|
||||||
|
|
||||||
import werkzeug.urls
|
import werkzeug.urls
|
||||||
import werkzeug.exceptions
|
import werkzeug.exceptions
|
||||||
|
@ -79,7 +78,7 @@ class GoogleAppsAwareConsumer(consumer.GenericConsumer):
|
||||||
# update fields
|
# update fields
|
||||||
for attr in ['claimed_id', 'identity']:
|
for attr in ['claimed_id', 'identity']:
|
||||||
value = message.getArg(consumer.OPENID2_NS, attr, '')
|
value = message.getArg(consumer.OPENID2_NS, attr, '')
|
||||||
value = 'https://www.google.com/accounts/o8/user-xrds?uri=%s' % urllib.quote_plus(value)
|
value = 'https://www.google.com/accounts/o8/user-xrds?uri=%s' % werkzeug.url_quote_plus(value)
|
||||||
message.setArg(consumer.OPENID2_NS, attr, value)
|
message.setArg(consumer.OPENID2_NS, attr, value)
|
||||||
|
|
||||||
# now, resign the message
|
# now, resign the message
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import simplejson
|
import simplejson
|
||||||
import urllib
|
import werkzeug.urls
|
||||||
|
|
||||||
import openerp
|
import openerp
|
||||||
import openerp.addons.web.controllers.main as webmain
|
import openerp.addons.web.controllers.main as webmain
|
||||||
|
@ -17,7 +17,7 @@ class EDI(openerp.http.Controller):
|
||||||
css = "\n ".join('<link rel="stylesheet" href="%s">' % i for i in webmain.manifest_list(req, modules_str, 'css'))
|
css = "\n ".join('<link rel="stylesheet" href="%s">' % i for i in webmain.manifest_list(req, modules_str, 'css'))
|
||||||
|
|
||||||
# `url` may contain a full URL with a valid query string, we basically want to watch out for XML brackets and double-quotes
|
# `url` may contain a full URL with a valid query string, we basically want to watch out for XML brackets and double-quotes
|
||||||
safe_url = urllib.quote_plus(url,':/?&;=')
|
safe_url = werkzeug.url_quote_plus(url,':/?&;=')
|
||||||
|
|
||||||
return webmain.html_template % {
|
return webmain.html_template % {
|
||||||
'js': js,
|
'js': js,
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
from urllib import quote_plus
|
|
||||||
import uuid
|
import uuid
|
||||||
from openerp import SUPERUSER_ID
|
from openerp import SUPERUSER_ID
|
||||||
|
|
||||||
|
|
|
@ -80,17 +80,7 @@ def slug(value):
|
||||||
return "%s-%d" % (slugify(name), id)
|
return "%s-%d" % (slugify(name), id)
|
||||||
|
|
||||||
def urlplus(url, params):
|
def urlplus(url, params):
|
||||||
if not params:
|
return werkzeug.Href(url)(params or None)
|
||||||
return url
|
|
||||||
|
|
||||||
# can't use urlencode because it encodes to (ascii, replace) in p2
|
|
||||||
return "%s?%s" % (url, '&'.join(
|
|
||||||
k + '=' + urllib.quote_plus(v.encode('utf-8') if isinstance(v, unicode) else str(v))
|
|
||||||
for k, v in params.iteritems()
|
|
||||||
))
|
|
||||||
|
|
||||||
def quote_plus(value):
|
|
||||||
return urllib.quote_plus(value.encode('utf-8') if isinstance(value, unicode) else str(value))
|
|
||||||
|
|
||||||
class website(osv.osv):
|
class website(osv.osv):
|
||||||
def _get_menu_website(self, cr, uid, ids, context=None):
|
def _get_menu_website(self, cr, uid, ids, context=None):
|
||||||
|
@ -243,7 +233,7 @@ class website(osv.osv):
|
||||||
slug=slug,
|
slug=slug,
|
||||||
res_company=request.website.company_id,
|
res_company=request.website.company_id,
|
||||||
user_id=user.browse(cr, uid, uid),
|
user_id=user.browse(cr, uid, uid),
|
||||||
quote_plus=quote_plus,
|
quote_plus=werkzeug.url_quote_plus,
|
||||||
)
|
)
|
||||||
qweb_values.setdefault('editable', False)
|
qweb_values.setdefault('editable', False)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import collections
|
import collections
|
||||||
import urllib
|
|
||||||
import urlparse
|
import urlparse
|
||||||
import unittest2
|
import unittest2
|
||||||
import urllib2
|
import urllib2
|
||||||
|
@ -66,7 +65,7 @@ class CrawlSuite(unittest2.TestSuite):
|
||||||
# blow up in multidb situations
|
# blow up in multidb situations
|
||||||
self.opener.open('http://localhost:{port}/web/?db={db}'.format(
|
self.opener.open('http://localhost:{port}/web/?db={db}'.format(
|
||||||
port=tools.config['xmlrpc_port'],
|
port=tools.config['xmlrpc_port'],
|
||||||
db=urllib.quote_plus(tools.config['db_name']),
|
db=werkzeug.url_quote_plus(tools.config['db_name']),
|
||||||
))
|
))
|
||||||
if user is not None:
|
if user is not None:
|
||||||
url = 'http://localhost:{port}/login?{query}'.format(
|
url = 'http://localhost:{port}/login?{query}'.format(
|
||||||
|
|
|
@ -4,13 +4,13 @@ from openerp.addons.web import http
|
||||||
from openerp.addons.web.http import request
|
from openerp.addons.web.http import request
|
||||||
from openerp import SUPERUSER_ID
|
from openerp import SUPERUSER_ID
|
||||||
|
|
||||||
from urllib import quote_plus
|
import werkzeug.urls
|
||||||
|
|
||||||
|
|
||||||
class contactus(http.Controller):
|
class contactus(http.Controller):
|
||||||
|
|
||||||
def generate_google_map_url(self, street, city, city_zip, country_name):
|
def generate_google_map_url(self, street, city, city_zip, country_name):
|
||||||
url = "http://maps.googleapis.com/maps/api/staticmap?center=%s&sensor=false&zoom=8&size=298x298" % quote_plus(
|
url = "http://maps.googleapis.com/maps/api/staticmap?center=%s&sensor=false&zoom=8&size=298x298" % werkzeug.url_quote_plus(
|
||||||
'%s, %s %s, %s' % (street, city, city_zip, country_name)
|
'%s, %s %s, %s' % (street, city, city_zip, country_name)
|
||||||
)
|
)
|
||||||
return url
|
return url
|
||||||
|
|
Loading…
Reference in New Issue