[Zope-CMF] formatRFC822Headers weakness?
r.ritz at biologie.hu-berlin.de
Wed Mar 10 06:53:51 EST 2004
When users on my site enter object descriptions (for the DC Description)
including blank lines or trailing newlines this breaks FTP (and
therefore ExternalEdit) support because these newlines also appear
in the RFC822 header causing a false parsing on re-upload.
I fixed this on my site by changing formatRFC822Headers in
def formatRFC822Headers( headers ):
""" Convert the key-value pairs in 'headers' to valid RFC822-style
headers, including adding leading whitespace to elements which
contain newlines in order to preserve continuation-line
munged = 
## linesplit = re.compile( r'[\n\r]+?' ) # changed to
linesplit = re.compile( r'[\n\r]+' )
for key, value in headers:
vallines = linesplit.split( value )
# added the following two lines (remove last line if empty)
if not vallines[-1]:
vallines = vallines[:-1]
munged.append( '%s: %s' % ( key, '\r\n '.join( vallines ) ) )
return '\r\n'.join( munged )
So far, I didn't notice breaking anything in other places but I only
tested external edit with emacs on Linux.
I don't have a windows system to check whether something might be
If people (Tres, Yuppie, ...) consider this safe, feel free to check it in.
More information about the Zope-CMF