use IO::Scalar;
use Params::Validate qw(validate_with :types);
+use Digest::MD5 qw(md5_hex);
+use Debbugs::Mail qw(get_addresses);
use Debbugs::MIME qw(convert_to_utf8 decode_rfc1522 create_mime_message);
use Debbugs::CGI qw(:url :html :util);
use Debbugs::Common qw(globify_scalar english_join);
not $param{terse} and
not exists $param{att}) {
my $header = $entity->head;
- print {$param{output}} "<pre class=\"headers\">\n";
+ print {$param{output}} "<div class=\"headers\">\n";
if ($param{trim_headers}) {
my @headers;
foreach (qw(From To Cc Subject Date)) {
my $head_field = $head->get($_);
next unless defined $head_field and $head_field ne '';
- push @headers, qq(<b>$_:</b> ) . html_escape(decode_rfc1522($head_field));
+ if ($_ eq 'From') {
+ push @headers,q(<img src=").__libravatar_url(decode_rfc1522($head_field)).q(">);
+ }
+ push @headers, qq(<p><span class="header">$_:</span> ) . html_escape(decode_rfc1522($head_field))."</p>";
}
print {$param{output}} join(qq(), @headers);
} else {
- print {$param{output}} html_escape(decode_rfc1522($entity->head->stringify));
+ print {$param{output}} "<pre>".html_escape(decode_rfc1522($entity->head->stringify))."</pre>\n";
}
- print {$param{output}} "</pre>\n";
+ print {$param{output}} "</div>\n";
}
if (not (($param{outer} and $type =~ m{^text(?:/plain)?(?:;|$)})
my $output = decode_utf8('');
local $_ = $record->{type};
if (/html/) {
- my ($time) = $record->{text} =~ /<!--\s+time:(\d+)\s+-->/;
- my $class = $record->{text} =~ /^<strong>(?:Acknowledgement|Reply|Information|Report|Notification)/m ? 'infmessage':'msgreceived';
- $output .= decode_rfc1522($record->{text});
+ # $record->{text} is not in perl's internal encoding; convert it
+ my $text = decode_utf8(decode_rfc1522($record->{text}));
+ my ($time) = $text =~ /<!--\s+time:(\d+)\s+-->/;
+ my $class = $text =~ /^<strong>(?:Acknowledgement|Reply|Information|Report|Notification)/m ? 'infmessage':'msgreceived';
+ $output .= $text;
# Link to forwarded http:// urls in the midst of the report
# (even though these links already exist at the top)
$output =~ s,((?:ftp|http|https)://[\S~-]+?/?)((?:[\)\'\:\.\,]|\&\#39;)?(?:\s|\.<|$)),<a href=\"$1\">$1</a>$2,go;
}
+sub __libravatar_url {
+ my ($email) = @_;
+ ($email) = get_addresses($email);
+ return "http://cdn.libravatar.org/avatar/".md5_hex(lc($email))."?d=retro";
+}
+
1;