Show More
@@ -308,13 +308,12 b' def headencode(ui, s, charsets=None, dis' | |||
|
308 | 308 | return s |
|
309 | 309 | |
|
310 | 310 | def _addressencode(ui, name, addr, charsets=None): |
|
311 | assert isinstance(addr, bytes) | |
|
311 | 312 | name = headencode(ui, name, charsets) |
|
312 | 313 | try: |
|
313 |
acc, dom = addr.split( |
|
|
314 | acc, dom = addr.split('@') | |
|
314 | 315 | acc = acc.encode('ascii') |
|
315 | if isinstance(dom, bytes): | |
|
316 | dom = dom.decode(encoding.encoding) | |
|
317 | dom = dom.encode('idna') | |
|
316 | dom = dom.decode(encoding.encoding).encode('idna') | |
|
318 | 317 | addr = '%s@%s' % (acc, dom) |
|
319 | 318 | except UnicodeDecodeError: |
|
320 | 319 | raise error.Abort(_('invalid email address: %s') % addr) |
@@ -332,7 +331,7 b' def addressencode(ui, address, charsets=' | |||
|
332 | 331 | if display or not address: |
|
333 | 332 | return address or '' |
|
334 | 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 | 336 | def addrlistencode(ui, addrs, charsets=None, display=False): |
|
338 | 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 | 346 | for name, addr in email.utils.getaddresses( |
|
348 | 347 | [encoding.strfromlocal(a) for a in addrs]): |
|
349 | 348 | if name or addr: |
|
350 |
r |
|
|
349 | r = _addressencode(ui, name, encoding.strtolocal(addr), charsets) | |
|
350 | result.append(r) | |
|
351 | 351 | return result |
|
352 | 352 | |
|
353 | 353 | def mimeencode(ui, s, charsets=None, display=False): |
General Comments 0
You need to be logged in to leave comments.
Login now