X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Fbin%2Fdisplay.cgi;h=10c706d98d0e13e2a59791e8625d462bc33ca882;hb=3c28a301742e8f8cdd35825fd6ebe4f842a510c7;hp=57ef8aa7a354cbb43261c7a64b41dfec8477b865;hpb=c769eb436f4b1c6358771b96f98fb11ca8676230;p=clearscm.git diff --git a/maps/bin/display.cgi b/maps/bin/display.cgi index 57ef8aa..10c706d 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); @@ -151,12 +151,12 @@ sub 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]}; @@ -171,15 +171,24 @@ sub Body ($) { $subpart->print_body; last; } # if - } # foreach + } # for } 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"; @@ -189,7 +198,7 @@ sub Body ($) { print end_table; } # Body -$userid = Heading ( +$userid = Heading( 'getcookie', '', "Email message from $sender", @@ -198,9 +207,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);