]> granicus.if.org Git - python/commitdiff
Two bug fixes for problems reported by Sverre:
authorBarry Warsaw <barry@python.org>
Sun, 4 Nov 2001 03:04:25 +0000 (03:04 +0000)
committerBarry Warsaw <barry@python.org>
Sun, 4 Nov 2001 03:04:25 +0000 (03:04 +0000)
__getaddr(): Watch out for empty addresses that can happen when
something like "MAIL FROM:<CR>" is received.  This avoids the
IndexError and rightly returns an SMTP syntax error.

parseargs(): We didn't handle the 2-arg case where both the localspec
and the remotespec were provided on the command line.

Lib/smtpd.py

index cf6821f2ba901b43e44a76011e94a545dff5ecb6..eb0a9b91f3c3afc74fbcce2ddde603acff90b70c 100755 (executable)
@@ -211,7 +211,9 @@ class SMTPChannel(asynchat.async_chat):
         keylen = len(keyword)
         if arg[:keylen].upper() == keyword:
             address = arg[keylen:].strip()
-            if address[0] == '<' and address[-1] == '>' and address != '<>':
+            if not address:
+                pass
+            elif address[0] == '<' and address[-1] == '>' and address != '<>':
                 # Addresses can be in the form <person@dom.com> but watch out
                 # for null address, e.g. <>
                 address = address[1:-1]
@@ -489,6 +491,9 @@ def parseargs():
     elif len(args) < 2:
         localspec = args[0]
         remotespec = 'localhost:25'
+    elif len(args) < 3:
+        localspec = args[0]
+        remotespec = args[1]
     else:
         usage(1, 'Invalid arguments: %s' % COMMASPACE.join(args))