Re: Bug in RFC822.py

Guido.van.Rossum@cwi.nl
Mon, 01 Aug 1994 15:09:15 +0200

> This module has worked fine for parsing 1000 different email addresses to our
> request server so far. But one message caused an error
>
...
> Reply-To: n.clifford@eleceng.ucl.ac.uk
> Reply-To: n.clifford@eleceng.ucl.ac.uk
...
>
> He had two "Reply-To:" fields!
> so getaddr('reply-to') returned:
> n.clifford@eleceng.ucl.ac.uk Reply-To: n.clifford@eleceng.ucl.ac.uk

(Steve also posted and then retracted a non-working fix.)

Here's a working fix -- replace getfirstmatchingheader() by the
following:

def getfirstmatchingheader(self, name):
name = string.lower(name) + ':'
n = len(name)
list = []
hit = 0
for line in self.headers:
if hit:
if line[:1] not in string.whitespace:
break
elif string.lower(line[:n]) == name:
hit = 1
if hit:
list.append(line)
return list

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
<URL:http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>