From 8d5b36dc3a4709df25a655831f7b346e6c48ca32 Mon Sep 17 00:00:00 2001 From: Nikolaus Schulz Date: Thu, 28 Sep 2006 23:26:58 +0000 Subject: 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. --- archivemail.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/archivemail.py b/archivemail.py index a0263a4..81ab69a 100755 --- a/archivemail.py +++ b/archivemail.py @@ -1233,17 +1233,18 @@ def _archive_imap(mailbox_name, final_archive_name): filter = build_imap_filter() vprint("imap filter: '%s'" % filter) try: + imap_username, imap_str = 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: - pass - imap_username = getpass.getuser() + unexpected_error("you must provide a properly formatted \ + IMAP connection string") if options.pwfile: imap_password = open(options.pwfile).read().rstrip() else: - imap_password = getpass.getpass() - imap_server, imap_folder = imap_str.split('/', 1) + try: + imap_username, imap_password = imap_username.split(':', 1) + except: + imap_password = getpass.getpass() if mailbox_name[:5] == 'imaps': vprint("Using SSL") -- cgit v1.2.3