X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=maps%2Fbin%2Fdisplay.cgi;h=10c706d98d0e13e2a59791e8625d462bc33ca882;hb=8a31102ba73e5acd0f089c68b83345484f31714b;hp=21f47b45da42de1296e478fd3b8d5cb01f938b27;hpb=020a4a5ea2be725b155cae3a2cadc9aba3911b9b;p=clearscm.git diff --git a/maps/bin/display.cgi b/maps/bin/display.cgi index 21f47b4..10c706d 100755 --- a/maps/bin/display.cgi +++ b/maps/bin/display.cgi @@ -2,7 +2,7 @@ ################################################################################ # # File: $RCSfile: display.cgi,v $ -# Revision: $Revision: 1.1 $ +# Revision: $Revision: 1.1 $ # Description: Displays an email message # Author: Andrew@DeFaria.com # Created: Fri Nov 29 14:17:21 2002 @@ -18,7 +18,7 @@ use warnings; use FindBin; $0 = $FindBin::Script; -use lib $FindBin::Bin; +use lib "$FindBin::Bin/../lib"; use MAPS; use MAPSWeb; @@ -30,19 +30,19 @@ use MIME::Parser; use MIME::Base64; use MIME::Words qw(:all); -my $userid = cookie ("MAPSUser"); -my $sender = param ("sender"); -my $msg_nbr = param ("msg_nbr"); -my $table_name = "message"; +my $userid = cookie('MAPSUser'); +my $sender = param('sender'); +my $msg_nbr = param('msg_nbr'); +my $table_name = 'message'; -sub ParseEmail (@) { +sub ParseEmail(@) { my (@header) = @_; my %header; # First output the header information. Note we'll skip uninteresting stuff - foreach (@header) { - last if ($_ eq "" || $_ eq "\cM"); + for (@header) { + last if ($_ eq '' || $_ eq "\cM"); # Escape "<" and ">" s/\\<\;/; @@ -56,13 +56,15 @@ sub ParseEmail (@) { $header{date} = $1; } elsif (/^To:\s*(.*)/i) { $header{to} = $1; + } elsif (/^Content-Transfer-Encoding: base64/) { + $header{base64} = 1; } # if - } # while + } # for return %header; } # ParseEmail -sub Body ($) { +sub Body($) { my ($count) = @_; $count ||= 1; @@ -76,7 +78,7 @@ sub Body ($) { ($userid, $sender, $subject, $timestamp, $message) = GetEmail $handle; } # for - my $parser = new MIME::Parser; + my $parser = MIME::Parser->new(); $parser->output_to_core (1); @@ -85,86 +87,108 @@ sub Body ($) { my %header = ParseEmail @{($entity->header)[0]}; print p . "\n"; - print start_table ({-align => "center", - -id => $table_name, - -border => 0, - -cellspacing => 0, - -cellpadding => 0, - -width => "100%"}); - print start_table ({-align => "center", - -bgcolor => "#d4d0c8", - -border => 0, - -cellspacing => 2, - -cellpadding => 2, - -width => "100%"}) . "\n"; + print start_table ({-align => "center", + -id => $table_name, + -border => 0, + -cellspacing => 0, + -cellpadding => 0, + -width => "100%"}); + print start_table ({-align => "center", + -bgcolor => "#d4d0c8", + -border => 0, + -cellspacing => 2, + -cellpadding => 2, + -width => "100%"}) . "\n"; print "
'; - $entity->print_body; - print ''; + if ($entity->{mail_inet_head}{mail_hdr_hash}{'Content-Transfer-Encoding'} and + ${$entity->{mail_inet_head}{mail_hdr_hash}{'Content-Transfer-Encoding'}[0]} =~ /base64/) { + print $entity->{ME_Bodyhandle}{MBS_Data}; + } else { + print '
'; + $entity->print_body; + print ''; + } # if } else { - foreach my $part ($entity->parts) { + for my $part ($entity->parts) { # We assume here that if this part is multipart/alternative then # there exists at least one part that is text/html and we favor # that (since we're outputing to a web page anyway... if ($part->mime_type eq 'multipart/alternative') { - foreach my $subpart ($part->parts) { - if ($subpart->mime_type eq 'text/html') { - $subpart->print_body; - last; - } elsif ($subpart->mime_type eq 'multipart/related') { - # This is stupid - multipart/related? When it's really just HTML?!? - $subpart->print_body; - last; - } # if - } # foreach + for my $subpart ($part->parts) { + if ($subpart->mime_type eq 'text/html') { + # There should be an easier way to get this but I couldn't find one. + my $encoding = ${$subpart->{mail_inet_head}{mail_hdr_hash}{'Content-Transfer-Encoding'}[0]}; + if ($encoding =~ /base64/) { + $subpart->bodyhandle->print(); + } else { + $subpart->print_body; + } # if + last; + } elsif ($subpart->mime_type eq 'multipart/related') { + # This is stupid - multipart/related? When it's really just HTML?!? + $subpart->print_body; + last; + } # if + } # for } else { - if ($part->mime_type =~ /text/) { - print '
'; - $part->print_body; - print ''; - } # if + if ($part->mime_type =~ /text/) { + my $encoding = ''; + + $encoding = ${$part->{mail_inet_head}{mail_hdr_hash}{'Content-Transfer-Encoding'}[0]} + if $part->{mail_inet_head}{mail_hdr_hash}{'Content-Transfer-Encoding'}; + + if ($encoding =~ /base64/) { + $part->bodyhandle->print(); + } else { + print '
'; + $part->print_body; + print ''; + } # if + } # if } # if - } # foreach + } # for } # if print "