A script for fixing bare newlines in mailbox files?

Jorey Bump list at joreybump.com
Fri Jan 12 12:18:15 EST 2007


Joseph Brennan wrote:

> When moving from U Wash to Cyrus we applied this rewrite to all
> mailboxes.  Get rid of any nulls while you're at it.
> 
> 
> while(<>) {
> 
>    # The \000 character (NUL) is not allowed
>    if ($line =~ s/\000//g) {
>       print STDERR "WARNING: Removing NUL\n";
>    }
> 
>    # Change CRLF or bare CR to LF
>    $endcr = $midcr = 0;
>    $endcr++ if ($line =~ s/\015$//g); # \n already there
>    $midcr++ if ($line =~ s/\015/\n/g); # add \n
>    if ($endcr || $midcr) {
>       print STDERR "WARNING: Correcting CR characters\n";
>     }
> 
> 
>    print;
> }

Did any users report any further corruption of what is arguably already 
a corrupted message? I'm not familiar with the cause of this problem, 
but having encountered it before, mainly with messages that have large 
attachments, I'm wondering if attached files might be unusable after 
such a scrubbing (assuming they were not encoded properly).



More information about the Info-cyrus mailing list