Show More
@@ -203,6 +203,7 b' test-http.t' | |||
|
203 | 203 | test-hybridencode.py |
|
204 | 204 | test-identify.t |
|
205 | 205 | test-import-bypass.t |
|
206 | test-import-eol.t | |
|
206 | 207 | test-import-merge.t |
|
207 | 208 | test-import-unknown.t |
|
208 | 209 | test-import.t |
@@ -11,6 +11,8 b' import email' | |||
|
11 | 11 | import email.charset |
|
12 | 12 | import email.header |
|
13 | 13 | import email.message |
|
14 | import email.parser | |
|
15 | import io | |
|
14 | 16 | import os |
|
15 | 17 | import smtplib |
|
16 | 18 | import socket |
@@ -322,6 +324,23 b' def mimeencode(ui, s, charsets=None, dis' | |||
|
322 | 324 | s, cs = _encode(ui, s, charsets) |
|
323 | 325 | return mimetextqp(s, 'plain', cs) |
|
324 | 326 | |
|
327 | if pycompat.ispy3: | |
|
328 | def parse(fp): | |
|
329 | ep = email.parser.Parser() | |
|
330 | # disable the "universal newlines" mode, which isn't binary safe. | |
|
331 | # I have no idea if ascii/surrogateescape is correct, but that's | |
|
332 | # what the standard Python email parser does. | |
|
333 | fp = io.TextIOWrapper(fp, encoding=r'ascii', | |
|
334 | errors=r'surrogateescape', newline=chr(10)) | |
|
335 | try: | |
|
336 | return ep.parse(fp) | |
|
337 | finally: | |
|
338 | fp.detach() | |
|
339 | else: | |
|
340 | def parse(fp): | |
|
341 | ep = email.parser.Parser() | |
|
342 | return ep.parse(fp) | |
|
343 | ||
|
325 | 344 | def headdecode(s): |
|
326 | 345 | '''Decodes RFC-2047 header''' |
|
327 | 346 | uparts = [] |
@@ -112,7 +112,7 b' def split(stream):' | |||
|
112 | 112 | cur.append(line) |
|
113 | 113 | c = chunk(cur) |
|
114 | 114 | |
|
115 |
m = |
|
|
115 | m = mail.parse(c) | |
|
116 | 116 | if not m.is_multipart(): |
|
117 | 117 | yield msgfp(m) |
|
118 | 118 | else: |
@@ -230,7 +230,7 b' def _extract(ui, fileobj, tmpname, tmpfp' | |||
|
230 | 230 | |
|
231 | 231 | data = {} |
|
232 | 232 | |
|
233 |
msg = |
|
|
233 | msg = mail.parse(fileobj) | |
|
234 | 234 | |
|
235 | 235 | subject = msg[r'Subject'] and mail.headdecode(msg[r'Subject']) |
|
236 | 236 | data['user'] = msg[r'From'] and mail.headdecode(msg[r'From']) |
@@ -295,10 +295,6 b' if ispy3:' | |||
|
295 | 295 | ret = shlex.split(s.decode('latin-1'), comments, posix) |
|
296 | 296 | return [a.encode('latin-1') for a in ret] |
|
297 | 297 | |
|
298 | def emailparser(*args, **kwargs): | |
|
299 | import email.parser | |
|
300 | return email.parser.BytesParser(*args, **kwargs) | |
|
301 | ||
|
302 | 298 | else: |
|
303 | 299 | import cStringIO |
|
304 | 300 | |
@@ -371,10 +367,6 b' else:' | |||
|
371 | 367 | rawinput = raw_input |
|
372 | 368 | getargspec = inspect.getargspec |
|
373 | 369 | |
|
374 | def emailparser(*args, **kwargs): | |
|
375 | import email.parser | |
|
376 | return email.parser.Parser(*args, **kwargs) | |
|
377 | ||
|
378 | 370 | isjython = sysplatform.startswith('java') |
|
379 | 371 | |
|
380 | 372 | isdarwin = sysplatform == 'darwin' |
General Comments 0
You need to be logged in to leave comments.
Login now