]> granicus.if.org Git - python/commitdiff
ehlo(): A proper fix for SF bug #498572. RFC 1869 describes ESMTP
authorBarry Warsaw <barry@python.org>
Mon, 15 Apr 2002 20:03:30 +0000 (20:03 +0000)
committerBarry Warsaw <barry@python.org>
Mon, 15 Apr 2002 20:03:30 +0000 (20:03 +0000)
which requires that if there are ehlo parameters returned with an ehlo
keyword (in the response to EHLO), the keyword and parameters must be
delimited by an ASCII space.  Thus responses like

    250-AUTH=LOGIN

should be ignored as non-conformant to the RFC (the `=' isn't allowed
in the ehlo keyword).

This is a bug fix candidate.

Lib/smtplib.py

index 6f37ceea1307d9bf49c26af27cc1d1b86425fb16..283616581fda67aac3fc7f9f09f0b3d538ba0b96 100755 (executable)
@@ -398,7 +398,11 @@ class SMTP:
         resp=self.ehlo_resp.split('\n')
         del resp[0]
         for each in resp:
-            m=re.match(r'(?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*)',each)
+            # RFC 1869 requires a space between ehlo keyword and parameters.
+            # It's actually stricter, in that only spaces are allowed between
+            # parameters, but were not going to check for that here.  Note
+            # that the space isn't present if there are no parameters.
+            m=re.match(r'(?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*) ?',each)
             if m:
                 feature=m.group("feature").lower()
                 params=m.string[m.end("feature"):].strip()