fix unicode

This commit is contained in:
kakwa 2015-06-27 22:35:34 +02:00
parent b5a8e302d1
commit 147cad3511
14 changed files with 26 additions and 9 deletions

View File

@ -372,6 +372,11 @@ class LdapCherry(object):
attrid = self.attributes.backend_attributes[b][attr]
if not attr in ret:
ret[attrid] = tmp[attr]
cherrypy.log.error(
msg = "user '" + username + "' attributes " + str(ret),
severity = logging.DEBUG
)
return ret
def _parse_params(self, params):

View File

@ -163,10 +163,10 @@ class Backend(ldapcherry.backend.Backend):
return dn_entry
def _str(self, s):
try:
return str(s)
except UnicodeEncodeError:
return unicode(s).encode('unicode_escape')
return s.encode('utf-8')
def _uni(self, s):
return s.decode('utf-8')
def auth(self, username, password):
@ -303,9 +303,9 @@ class Backend(ldapcherry.backend.Backend):
for attr in attrs_tmp:
value_tmp = attrs_tmp[attr]
if len(value_tmp) == 1:
attrs[attr] = value_tmp[0]
attrs[attr] = self._uni(value_tmp[0])
else:
attrs[attr] = value_tmp
attrs[attr] = map(self._uni, value_tmp)
if self.key in attrs:
ret[attrs[self.key]] = attrs
@ -317,9 +317,9 @@ class Backend(ldapcherry.backend.Backend):
for attr in attrs_tmp:
value_tmp = attrs_tmp[attr]
if len(value_tmp) == 1:
ret[attr] = value_tmp[0]
ret[attr] = self._uni(value_tmp[0])
else:
ret[attr] = value_tmp
ret[attr] = map(self._uni, value_tmp)
return ret
def get_groups(self, username):
@ -333,5 +333,5 @@ class Backend(ldapcherry.backend.Backend):
groups = self._search(searchfilter, NO_ATTR, self.groupdn)
ret = []
for entry in groups:
ret.append(entry[0])
ret.append(self._uni(entry[0]))
return ret

View File

@ -1,3 +1,4 @@
## -*- coding: utf-8 -*-
<%inherit file="navbar.tmpl"/>
<%block name="core">
<div class="row clearfix top-buffer bottom-buffer">

View File

@ -1,3 +1,4 @@
## -*- coding: utf-8 -*-
<!DOCTYPE html>
<html>
<head>

View File

@ -1,3 +1,4 @@
## -*- coding: utf-8 -*-
<%inherit file="navbar.tmpl"/>
<%block name="core">
<div class="row clearfix">

View File

@ -1,3 +1,4 @@
## -*- coding: utf-8 -*-
<%
len_attr = len(attributes)
switch = len_attr / 2

View File

@ -1,3 +1,4 @@
## -*- coding: utf-8 -*-
<%inherit file="navbar.tmpl"/>
<%block name="core">
</%block>

View File

@ -1,3 +1,4 @@
## -*- coding: utf-8 -*-
<%inherit file="base.tmpl"/>
<%block name="core">
<div class="row clearfix" style="margin-top:30px">

View File

@ -1,3 +1,4 @@
## -*- coding: utf-8 -*-
<%inherit file="navbar.tmpl"/>
<%block name="core">
<div class="row clearfix top-buffer bottom-buffer">

View File

@ -1,3 +1,4 @@
## -*- coding: utf-8 -*-
#<%inherit file="base.tmpl"/>
<%block name="navbar">
<div class="row clearfix">

View File

@ -1,3 +1,4 @@
## -*- coding: utf-8 -*-
<script type="text/javascript">
var graph = ${graph_js};
var roles = ${roles_js};

View File

@ -1,3 +1,4 @@
## -*- coding: utf-8 -*-
<%inherit file="navbar.tmpl"/>
<%block name="core">
<div class="row clearfix">

View File

@ -1,3 +1,4 @@
## -*- coding: utf-8 -*-
<%inherit file="navbar.tmpl"/>
<%block name="core">
<div class="row clearfix">

View File

@ -1,3 +1,4 @@
## -*- coding: utf-8 -*-
<%inherit file="navbar.tmpl"/>
<%block name="core">
<div class="row clearfix top-buffer bottom-buffer">