AddrlistClass.getaddress(): when parsing `:'s, in the loop, watch out

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').
This commit is contained in:
Barry Warsaw 1999-07-12 18:37:02 +00:00
parent 860e256147
commit 96e9bf45e8
1 changed files with 2 additions and 1 deletions

View 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()