aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolaus Schulz <microschulz@web.de>2006-09-28 23:26:58 +0000
committerNikolaus Schulz <microschulz@web.de>2006-09-28 23:26:58 +0000
commit8d5b36dc3a4709df25a655831f7b346e6c48ca32 (patch)
treededb8f3b0c61357e92e2b8841b042b8caa209ee9
parentdc023db8954d5a4fa6e14986c7a2be6fcebd8313 (diff)
downloadarchivemail-8d5b36dc3a4709df25a655831f7b346e6c48ca32.tar.gz
archivemail-8d5b36dc3a4709df25a655831f7b346e6c48ca32.tar.bz2
archivemail-8d5b36dc3a4709df25a655831f7b346e6c48ca32.zip
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.
-rwxr-xr-xarchivemail.py13
1 files 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")