X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Fbin%2Fdisplay.cgi;h=57ef8aa7a354cbb43261c7a64b41dfec8477b865;hb=5a999d10367482dbdcdb5963e2ec8f5d8332db93;hp=21f47b45da42de1296e478fd3b8d5cb01f938b27;hpb=020a4a5ea2be725b155cae3a2cadc9aba3911b9b;p=clearscm.git diff --git a/maps/bin/display.cgi b/maps/bin/display.cgi index 21f47b4..57ef8aa 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 @@ -30,10 +30,10 @@ 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 (@) { my (@header) = @_; @@ -42,7 +42,7 @@ sub ParseEmail (@) { # First output the header information. Note we'll skip uninteresting stuff foreach (@header) { - last if ($_ eq "" || $_ eq "\cM"); + last if ($_ eq '' || $_ eq "\cM"); # Escape "<" and ">" s/\\<\;/; @@ -56,6 +56,8 @@ sub ParseEmail (@) { $header{date} = $1; } elsif (/^To:\s*(.*)/i) { $header{to} = $1; + } elsif (/^Content-Transfer-Encoding: base64/) { + $header{base64} = 1; } # if } # while @@ -85,84 +87,97 @@ 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) { # 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 + foreach 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 + } # foreach } else { - if ($part->mime_type =~ /text/) { - print '
'; - $part->print_body; - print ''; - } # if + if ($part->mime_type =~ /text/) { + print '
'; + $part->print_body; + print ''; + } # if } # if } # foreach } # if @@ -175,11 +190,11 @@ sub Body ($) { } # Body $userid = Heading ( - "getcookie", - "", + 'getcookie', + '', "Email message from $sender", "Email message from $sender", - "", + '', $table_name, );