1
0
mirror of https://github.com/laurivosandi/certidude synced 2024-12-22 16:25:17 +00:00

Improve Unicode handling in bundle generation

This commit is contained in:
Lauri Võsandi 2016-09-18 14:32:14 +03:00
parent 9cf5e298e8
commit 1b04a848e3
2 changed files with 9 additions and 8 deletions

View File

@ -8,10 +8,10 @@ from certidude.auth import login_required
logger = logging.getLogger("api")
KEYWORDS = (
("Android", "android"),
("iPhone", "iphone"),
("iPad", "ipad"),
("Ubuntu", "ubuntu"),
(u"Android", u"android"),
(u"iPhone", u"iphone"),
(u"iPad", u"ipad"),
(u"Ubuntu", u"ubuntu"),
)
class BundleResource(object):
@ -24,9 +24,10 @@ class BundleResource(object):
device_identifier = value
break
else:
device_identifier = "unknown-device"
common_name += "@" + device_identifier + "-" + \
hashlib.sha256(req.user_agent).hexdigest()[:8]
device_identifier = u"unknown-device"
common_name = u"%s@%s-%s" % (common_name, device_identifier, \
hashlib.sha256(req.user_agent).hexdigest()[:8])
logger.info(u"Signing bundle %s for %s", common_name, req.context.get("user"))
resp.set_header("Content-Type", "application/x-pkcs12")
resp.set_header("Content-Disposition", "attachment; filename=%s.p12" % common_name.encode("ascii"))

View File

@ -46,7 +46,7 @@ class PosixUserManager(object):
_, _, _, _, gecos, _, _ = pwd.getpwnam(username)
gecos = gecos.decode("utf-8").split(",")
full_name = gecos[0]
mail = username + "@" + const.DOMAIN
mail = u"%s@%s" % (username, const.DOMAIN)
if full_name and " " in full_name:
given_name, surname = full_name.split(" ", 1)
return User(username, mail, given_name, surname)