]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
AddrlistClass.getaddress(): when parsing `:'s, in the loop, watch out
authorBarry Warsaw <barry@python.org>
Mon, 12 Jul 1999 18:37:02 +0000 (18:37 +0000)
committerBarry Warsaw <barry@python.org>
Mon, 12 Jul 1999 18:37:02 +0000 (18:37 +0000)
for gotonext() pushing self.pos past the end of the string.  This can
happen if the message has a To field like "To: :" and you call
msg.getaddrlist('to').

Lib/rfc822.py

index 662703beca3b74860ed99a4fac7b3d02097d8745..7030ee7cb3152a70e5b5ac04ec16559b928499e0 100644 (file)
@@ -553,10 +553,11 @@ class AddrlistClass:
             # address is a group
             returnlist = []
             
+            fieldlen = len(self.field)
             self.pos = self.pos + 1
             while self.pos < len(self.field):
                 self.gotonext()
-                if self.field[self.pos] == ';':
+                if self.pos < fieldlen and self.field[self.pos] == ';':
                     self.pos = self.pos + 1
                     break
                 returnlist = returnlist + self.getaddress()