X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FCGI%2FBugreport.pm;h=29602c58c39f1088bc17208e49ab28c1561ac152;hb=23d26116c0fcfeeaf60a7ab724f18fe86554d746;hp=0b19bab636029b1d0324fe6fffc7b242ff6c8587;hpb=de30c269182d7c865eb3d1258387485dd5131819;p=debbugs.git diff --git a/Debbugs/CGI/Bugreport.pm b/Debbugs/CGI/Bugreport.pm index 0b19bab..29602c5 100644 --- a/Debbugs/CGI/Bugreport.pm +++ b/Debbugs/CGI/Bugreport.pm @@ -32,9 +32,12 @@ use base qw(Exporter); use IO::Scalar; use Params::Validate qw(validate_with :types); -use Debbugs::MIME qw(convert_to_utf8 decode_rfc1522 create_mime_message); +use Digest::MD5 qw(md5_hex); +use Debbugs::Mail qw(get_addresses); +use Debbugs::MIME qw(decode_rfc1522 create_mime_message); use Debbugs::CGI qw(:url :html :util); use Debbugs::Common qw(globify_scalar english_join); +use Debbugs::UTF8; use Debbugs::Config qw(:config); use POSIX qw(strftime); use Encode qw(decode_utf8); @@ -132,19 +135,25 @@ sub display_entity { not $param{terse} and not exists $param{att}) { my $header = $entity->head; - print {$param{output}} "
\n";
+	 print {$param{output}} "
\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($_: ) . html_escape(decode_rfc1522($head_field)); + if ($_ eq 'From') { + my $libravatar_url = __libravatar_url(decode_rfc1522($head_field)); + if (defined $libravatar_url and length $libravatar_url) { + push @headers,q(); + } + } + push @headers, qq(

$_: ) . html_escape(decode_rfc1522($head_field))."

"; } print {$param{output}} join(qq(), @headers); } else { - print {$param{output}} html_escape(decode_rfc1522($entity->head->stringify)); + print {$param{output}} "
".html_escape(decode_rfc1522($entity->head->stringify))."
\n"; } - print {$param{output}} "
\n"; + print {$param{output}} "\n"; } if (not (($param{outer} and $type =~ m{^text(?:/plain)?(?:;|$)}) @@ -333,9 +342,11 @@ sub handle_record{ my $output = decode_utf8(''); local $_ = $record->{type}; if (/html/) { - my ($time) = $record->{text} =~ //; - my $class = $record->{text} =~ /^(?: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_rfc1522(decode_utf8($record->{text})); + my ($time) = $text =~ //; + my $class = $text =~ /^(?: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|\.<|$)),$1$2,go; @@ -423,6 +434,15 @@ sub handle_record{ } +sub __libravatar_url { + my ($email) = @_; + if (not defined $config{libravatar_uri} or not length $config{libravatar_uri}) { + return undef; + } + ($email) = get_addresses($email); + return $config{libravatar_uri}.md5_hex(lc($email)).($config{libravatar_uri_options}//''); +} + 1;