unstick r1862550

Revision 1862550

Date:
2019/07/04 12:21:36
Author:
humbedooh
Revision Log:
Properly deal with unicode characters in emails by converting the lot to UTF-8. (TODO: use asfpy??)
Files:

Legend:

 
Added
 
Removed
 
Modified
  • steve/trunk/pysteve/lib/voter.py

     
    36 36 xhash = hashlib.sha512(basedata['hash'] + uid).hexdigest()
    37 37 return backend.voter_get_uid(election, xhash)
    38 38
    39
    39
    40 40 def add(election, basedata, PID):
    41 41 uid = hashlib.sha224("%s%s%s%s" % (PID, basedata['hash'], time.time(), random.randint(1,99999999))).hexdigest()
    42 42 xhash = hashlib.sha512(basedata['hash'] + uid).hexdigest()
     
    81 81 sender = config.get("email", "sender")
    82 82 signature = config.get("email", "signature")
    83 83 receivers = [rcpt]
    84 msg = """From: %s
    84 # py 2 vs 3 conversion
    85 if type(message) is bytes:
    86 message = message.decode('utf-8', errors='replace')
    87 msg = u"""From: %s
    85 88 To: %s
    86 89 Subject: %s
    87 90
     
    92 95 --
    93 96 Powered by Apache STeVe - https://steve.apache.org
    94 97 """ % (sender, rcpt, subject, message, signature)
    95
    98 msg = msg.encode('utf-8', errors='replace')
    96 99 try:
    97 100 smtpObj = smtplib.SMTP(config.get("email", "mta"))
    98 101 smtpObj.sendmail(sender, receivers, msg)