##// END OF EJS Templates
mail: pass in addr to _addressencode() in bytes...
Yuya Nishihara -
r39142:ebf54a34 default
parent child Browse files
Show More
@@ -308,13 +308,12 b' def headencode(ui, s, charsets=None, dis'
308 return s
308 return s
309
309
310 def _addressencode(ui, name, addr, charsets=None):
310 def _addressencode(ui, name, addr, charsets=None):
311 assert isinstance(addr, bytes)
311 name = headencode(ui, name, charsets)
312 name = headencode(ui, name, charsets)
312 try:
313 try:
313 acc, dom = addr.split(r'@')
314 acc, dom = addr.split('@')
314 acc = acc.encode('ascii')
315 acc = acc.encode('ascii')
315 if isinstance(dom, bytes):
316 dom = dom.decode(encoding.encoding).encode('idna')
316 dom = dom.decode(encoding.encoding)
317 dom = dom.encode('idna')
318 addr = '%s@%s' % (acc, dom)
317 addr = '%s@%s' % (acc, dom)
319 except UnicodeDecodeError:
318 except UnicodeDecodeError:
320 raise error.Abort(_('invalid email address: %s') % addr)
319 raise error.Abort(_('invalid email address: %s') % addr)
@@ -332,7 +331,7 b' def addressencode(ui, address, charsets='
332 if display or not address:
331 if display or not address:
333 return address or ''
332 return address or ''
334 name, addr = email.utils.parseaddr(encoding.strfromlocal(address))
333 name, addr = email.utils.parseaddr(encoding.strfromlocal(address))
335 return _addressencode(ui, name, addr, charsets)
334 return _addressencode(ui, name, encoding.strtolocal(addr), charsets)
336
335
337 def addrlistencode(ui, addrs, charsets=None, display=False):
336 def addrlistencode(ui, addrs, charsets=None, display=False):
338 '''Turns a list of addresses into a list of RFC-2047 compliant headers.
337 '''Turns a list of addresses into a list of RFC-2047 compliant headers.
@@ -347,7 +346,8 b' def addrlistencode(ui, addrs, charsets=N'
347 for name, addr in email.utils.getaddresses(
346 for name, addr in email.utils.getaddresses(
348 [encoding.strfromlocal(a) for a in addrs]):
347 [encoding.strfromlocal(a) for a in addrs]):
349 if name or addr:
348 if name or addr:
350 result.append(_addressencode(ui, name, addr, charsets))
349 r = _addressencode(ui, name, encoding.strtolocal(addr), charsets)
350 result.append(r)
351 return result
351 return result
352
352
353 def mimeencode(ui, s, charsets=None, display=False):
353 def mimeencode(ui, s, charsets=None, display=False):
General Comments 0
You need to be logged in to leave comments. Login now