#!/opt/local/bin/perl # # turns a textfile containing an email message into an html page for the # cssn website # # Copyright 2000 Michael Castleman. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Note that the GNU General Public License, found here in the file # COPYING, applies only to the script makehtml.pl, not to any input or # output files of that script. # I hereby note that the output of this script should NOT be considered # a derived work for the purposes of copyleft/right, even though it may # contain strings from this code. # use strict; sub fixup ( \$ ); my $subj; my @headers; my $havesubj = 0; do { $_ = <>; chomp; fixup $_; push @headers, $_; if ($havesubj && /^\s/) { s/^\s+/ /; $subj .= $_; } elsif (/^Subject: (.*)$/) { $subj = $1; $havesubj = 1; } else { $havesubj = 0; } } while ($_ ne ""); print '
';
foreach (@headers) { print "$_\n" }
while (<>) {
fixup $_;
print;
}
print "\n";
sub fixup ( \$ ) {
my $f = $_[0];
# replace special characters with entities
$$f =~ s/\&/\&\;/g;
$$f =~ s/\\<\;/g;
$$f =~ s/\>/\>\;/g;
# hyperlink emails and URLs
$$f =~ s/([\w\-]+\@[\w\-\.]+)/\$1\<\/a\>/g;
$$f =~ s/([a-z]+\:\/\/[^\s]+)/\$1\<\/a\>/g;
}