Commit 5a430b27 authored by Remi Oudin's avatar Remi Oudin

Corrections de multiples bugs d'encodage dans le wiki.

parent 6ffb92b7
......@@ -52,7 +52,7 @@ class AnonymousAuth(BaseAuth):
p = urlparse.urlparse(request.url)
# Prevent preference edition and quicklink when anonymous
if action == "userprefs" or action == "quicklink":
url = urlparse.urlunparse(('https', p.netloc, p.path, "", "", ""))
url = urlparse.urlunparse(('https', p.netloc, p.path, "", "", "")).encode('utf8')
request.http_redirect(url)
......
......@@ -38,21 +38,22 @@ class PyCAS(object):
def login_url(self, service):
"""Return the login URL for the given service."""
url = self.server_url + self.login_path + '?service=' + urllib.quote_plus(service)
url = self.server_url + self.login_path + '?service=' + urllib.quote_plus(service.encode('utf8'))
if self.renew:
url += "&renew=true"
return url
return url.decode('utf8')
def logout_url(self, redirect_url=None):
"""Return the logout URL."""
url = self.server_url + self.logout_path
if redirect_url:
url += '?url=' + urllib.quote_plus(redirect_url)
url += '&service=' + urllib.quote_plus(redirect_url)
url += '?url=' + urllib.quote_plus(redirect_url.encode('utf8'))
url += '&service=' + urllib.quote_plus(redirect_url.encode('utf8'))
return url
def validate_url(self, service, ticket):
"""Return the validation URL for the given service. (For CAS 1.0)"""
url = self.server_url + self.validate_path + '?service=' + urllib.quote_plus(service) + '&ticket=' + urllib.quote_plus(ticket)
url = self.server_url + self.validate_path + '?service=' + urllib.quote_plus(service.encode('utf8')) + '&ticket=' + urllib.quote_plus(ticket)
if self.renew:
url += "&renew=true"
return url
......@@ -136,14 +137,14 @@ class CASAuth(BaseAuth):
if self.ticket_path and request.method == 'POST':
logoutRequest=request.form.get('logoutRequest', None)
if logoutRequest is not None:
sys.stderr.write("Tentative de deconnexion du CAS : %s\n" % logoutRequest)
sys.stderr.write("Tentative de déconnexion du CAS : %s\n" % logoutRequest.decode('ascii', 'ignore'))
self.cas.singlesignout(logout_user, logoutRequest)
# valid ticket on CAS
if ticket and ticket.startswith('ST-'):
valid, username = self.cas.validate_ticket(url, ticket)
if valid:
sys.stderr.write("Authentifiaction de %s sur le CAS\n" % username)
sys.stderr.write("Authentifiction de %s sur le CAS\n" % username)
u = user.User(request, auth_username=username, auth_method=self.name)
# auto create user ?
if self.create_user:
......
......@@ -53,14 +53,14 @@ class PublicCategories(AnonymousAuth):
sys.stderr.write("%r dans la page %r\n" % (cat, p.path[1:]))
return True
else:
sys.stderr.write("categories is empty, searching in page body of %s\n" % p.path[1:])
sys.stderr.write("categories is empty, searching in page body of %s\n" % p.path[1:].encode('utf8'))
body = page.getPageText()
for cat in self.pub_cats:
if cat in body:
sys.stderr.write("%r dans la page %r\n" % (cat, p.path[1:]))
sys.stderr.write("%s dans la page %s\n" % (cat.encode('utf8'), p.path[1:].encode('utf8')))
return True
sys.stderr.write("%r n'est pas dans la page %r, %r\n" % (cat, p.path[1:], categories))
sys.stderr.write("%s n'est pas dans la page %s, %r\n" % (cat.encode('utf8'), p.path[1:].encode('utf8'), categories))
return False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment