A script for fixing bare newlines in mailbox files?
Joseph Brennan
brennan at columbia.edu
Fri Jan 12 08:45:37 EST 2007
--On Thursday, January 11, 2007 17:35 -0500 Zachariah Mully
<zmully at smartbrief.com> wrote:
> Howdy all-
> We've been bitten by migrating some of our people from Outlook to
> Thunderbird, and then using Tbird to move their mail off their local
> machines onto the IMAP server where it belongs. Unfortunately we've not
> patched Cyrus to accept bare newlines, nor intend to... Since I have
> access to the local mailboxes does anybody have a perl script or
> something of the like that would remove the bare newlines from the raw
> mailbox files? My perl-fu sucks this days, and I've not been able to
> figure where and how to remove them...
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;
}
Joseph Brennan
Lead Email Systems Engineer
Columbia University Information Technology
More information about the Info-cyrus
mailing list