1
0
Fork 0
mirror of https://git.code.sf.net/p/archivemail/code synced 2024-12-23 08:14:58 +00:00

Fixed IMAP authentication/URL parsing. Require username encoded in URL, but be

flexible with the password: handle both --pwfile and URL-encoded password, and
fallback to querying the user if neither is present.
This commit is contained in:
Nikolaus Schulz 2006-09-28 23:26:58 +00:00
parent dc023db895
commit 8d5b36dc3a

View file

@ -1233,17 +1233,18 @@ def _archive_imap(mailbox_name, final_archive_name):
filter = build_imap_filter() filter = build_imap_filter()
vprint("imap filter: '%s'" % filter) vprint("imap filter: '%s'" % filter)
try: try:
imap_username, imap_str = imap_str.split('@', 1)
imap_server, imap_folder = imap_str.split('/', 1) imap_server, imap_folder = imap_str.split('/', 1)
imap_username, imap_str = imap_str.split(':', 1)
imap_password, imap_str = imap_str.split('@', 1)
except: except:
pass unexpected_error("you must provide a properly formatted \
imap_username = getpass.getuser() IMAP connection string")
if options.pwfile: if options.pwfile:
imap_password = open(options.pwfile).read().rstrip() imap_password = open(options.pwfile).read().rstrip()
else: else:
imap_password = getpass.getpass() try:
imap_server, imap_folder = imap_str.split('/', 1) imap_username, imap_password = imap_username.split(':', 1)
except:
imap_password = getpass.getpass()
if mailbox_name[:5] == 'imaps': if mailbox_name[:5] == 'imaps':
vprint("Using SSL") vprint("Using SSL")