Author: humbedooh
Date: Thu Jul 4 12:21:36 2019
New Revision: 1862550
URL: http://svn.apache.org/viewvc?rev=1862550&view=rev
Log:
Properly deal with unicode characters in emails by converting the lot to UTF-8.
(TODO: use asfpy??)
Modified:
steve/trunk/pysteve/lib/voter.py
Modified: steve/trunk/pysteve/lib/voter.py
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/voter.py?rev=1862550&r1=1862549&r2=1862550&view=diff
==============================================================================
--- steve/trunk/pysteve/lib/voter.py (original)
+++ steve/trunk/pysteve/lib/voter.py Thu Jul 4 12:21:36 2019
@@ -36,7 +36,7 @@ def get(election, basedata, uid):
xhash = hashlib.sha512(basedata['hash'] + uid).hexdigest()
return backend.voter_get_uid(election, xhash)
-
+
def add(election, basedata, PID):
uid = hashlib.sha224("%s%s%s%s" % (PID, basedata['hash'], time.time(),
random.randint(1,99999999))).hexdigest()
xhash = hashlib.sha512(basedata['hash'] + uid).hexdigest()
@@ -81,7 +81,10 @@ def email(rcpt, subject, message):
sender = config.get("email", "sender")
signature = config.get("email", "signature")
receivers = [rcpt]
- msg = """From: %s
+ # py 2 vs 3 conversion
+ if type(message) is bytes:
+ message = message.decode('utf-8', errors='replace')
+ msg = u"""From: %s
To: %s
Subject: %s
@@ -92,7 +95,7 @@ With regards,
--
Powered by Apache STeVe - https://steve.apache.org
""" % (sender, rcpt, subject, message, signature)
-
+ msg = msg.encode('utf-8', errors='replace')
try:
smtpObj = smtplib.SMTP(config.get("email", "mta"))
smtpObj.sendmail(sender, receivers, msg)