X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Fbin%2Fdisplay.cgi;h=76f5ab6fef6f541c65aba432c9ad920f9c502e79;hb=35fe4cfe672324222cf787218d007f119eb446f8;hp=7c4e3b84471da01b3366aefd490067dfcdc84cc4;hpb=fb0ec106a8deca35bebe0713ecd45b37fc41670c;p=clearscm.git diff --git a/maps/bin/display.cgi b/maps/bin/display.cgi index 7c4e3b8..76f5ab6 100755 --- a/maps/bin/display.cgi +++ b/maps/bin/display.cgi @@ -18,7 +18,7 @@ use warnings; use FindBin; $0 = $FindBin::Script; -use lib $FindBin::Bin; +use lib "$FindBin::Bin/../lib"; use MAPS; use MAPSWeb; @@ -35,13 +35,13 @@ 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) { + for (@header) { last if ($_ eq '' || $_ eq "\cM"); # Escape "<" and ">" @@ -59,12 +59,12 @@ sub ParseEmail (@) { } elsif (/^Content-Transfer-Encoding: base64/) { $header{base64} = 1; } # if - } # while + } # for return %header; } # ParseEmail -sub Body ($) { +sub Body($) { my ($count) = @_; $count ||= 1; @@ -78,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); @@ -142,16 +142,21 @@ sub Body ($) { my @parts = $entity->parts; if (scalar @parts == 0) { - 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) { + 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]}; @@ -166,15 +171,27 @@ sub Body ($) { $subpart->print_body; last; } # if - } # foreach + } # for + } elsif ($part->mime_type eq 'multipart/related') { + # Sometimes parts are 'multipart/relative'... + $part->print_body; } else { if ($part->mime_type =~ /text/) { - print '
'; - $part->print_body; - print ''; + 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 "\n"; @@ -184,7 +201,7 @@ sub Body ($) { print end_table; } # Body -$userid = Heading ( +$userid = Heading( 'getcookie', '', "Email message from $sender", @@ -193,9 +210,9 @@ $userid = Heading ( $table_name, ); -SetContext $userid; -NavigationBar $userid; +SetContext($userid); +NavigationBar($userid); -Body $msg_nbr; +Body($msg_nbr); -Footing $table_name; +Footing($table_name);