X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FCGI%2FBugreport.pm;h=00619fc47a70d99a0b1c50fc9575760a510e576c;hb=4c244879af2b9e8c0055968d7ffb054646cb7607;hp=d9a8744ec246a8fad827b4a15790b92b2137668f;hpb=7b81a1095047ef5126801584fae1e6b9312f9558;p=debbugs.git diff --git a/Debbugs/CGI/Bugreport.pm b/Debbugs/CGI/Bugreport.pm index d9a8744..00619fc 100644 --- a/Debbugs/CGI/Bugreport.pm +++ b/Debbugs/CGI/Bugreport.pm @@ -33,7 +33,7 @@ use base qw(Exporter); use IO::Scalar; use Params::Validate qw(validate_with :types); use Digest::MD5 qw(md5_hex); -use Debbugs::Mail qw(get_addresses); +use Debbugs::Mail qw(get_addresses :reply); use Debbugs::MIME qw(decode_rfc1522 create_mime_message); use Debbugs::CGI qw(:url :html :util); use Debbugs::Common qw(globify_scalar english_join); @@ -41,6 +41,8 @@ use Debbugs::UTF8; use Debbugs::Config qw(:config); use POSIX qw(strftime); use Encode qw(decode_utf8 encode_utf8); +use URI::Escape qw(uri_escape_utf8); +use Scalar::Util qw(blessed); BEGIN{ ($VERSION) = q$Revision: 494 $ =~ /^Revision:\s+([^\s+])/; @@ -137,9 +139,8 @@ sub display_entity { if ($param{outer} and not $param{terse} and not exists $param{att}) { - my $header = $entity->head; print {$output} "
\n"; - if ($param{trim_headers}) { + if ($param{trim_headers}) { my @headers; foreach (qw(From To Cc Subject Date)) { my $head_field = $head->get($_); @@ -148,7 +149,7 @@ sub display_entity { if ($_ eq 'From' and $param{avatars}) { my $libravatar_url = __libravatar_url(decode_rfc1522($head_field)); if (defined $libravatar_url and length $libravatar_url) { - push @headers,q(\n); + push @headers,q(\n); } } push @headers, qq(
$_: ) . html_escape(decode_rfc1522($head_field))."
\n"; @@ -270,10 +271,14 @@ sub display_entity { # We don't html escape here because we escape above; # wierd terminators are because of that $body =~ s{((?:ftp|http|https|svn|ftps|rsync)://[\S~-]+?/?) # Url - ((?:\>\;)?[)]?(?:'|\&\#39\;)?[:.\,]?(?:\s|$)) # terminators + ((?:\>\;)?[)]?(?:'|\&\#39\;|\"\;)?[:.\,]?(?:\s|$)) # terminators }{$1$2}gox; # Add links to bug closures - $body =~ s[(closes:\s*(?:bug)?\#?\s?\d+(?:,?\s*(?:bug)?\#?\s?\d+)*)] + $body =~ s[((?:closes|see):\s* # start of closed/referenced bugs + (?:bug)?\#?\s?\d+\s? # first bug + (?:,?\s*(?:bug)?\#?\s?\d+)* # additional bugs + (?:\s|\n|\)|\]|\}|\.|\,|$)) # ends with a space, newline, end of string, or ); fixes #747267 + ] [my $temp = $1; $temp =~ s{(\d+)} {bug_links(bug=>$1)}ge; @@ -282,7 +287,7 @@ sub display_entity { length $config{cve_tracker} ) { # Add links to CVE vulnerabilities (closes #568464) - $body =~ s{(^|\s)(CVE-\d{4}-\d{4,})(\s|[,.-\[\]]|$)} + $body =~ s{(^|\s|[\(\[])(CVE-\d{4}-\d{4,})(\s|[,.-\[\]\)]|$)} {$1$2$3}gxm; } if (not exists $param{att}) { @@ -311,12 +316,17 @@ sub handle_email_message{ my $output; my $output_fh = globify_scalar(\$output); - my $parser = MIME::Parser->new(); - # Because we are using memory, not tempfiles, there's no need to - # clean up here like in Debbugs::MIME - $parser->tmp_to_core(1); - $parser->output_to_core(1); - my $entity = $parser->parse_data( $email); + my $entity; + if (not blessed $email) { + my $parser = MIME::Parser->new(); + # Because we are using memory, not tempfiles, there's no need to + # clean up here like in Debbugs::MIME + $parser->tmp_to_core(1); + $parser->output_to_core(1); + $entity = $parser->parse_data( $email); + } else { + $entity = $email + } my @attachments = (); my $raw_output = display_entity(entity => $entity, @@ -376,7 +386,7 @@ sub handle_record{ {$1.$2.(bug_links(bug=>$3)).$4. english_join([map {bug_links(bug=>$_)} (split /\,?\s+(?:and\s+)?/, $5)])}eo; # Add links to reassigned packages - $output =~ s{(Bug reassigned from package \`)([^']+?)((?:'|\&\#39;) to \`)([^']+?)((?:'|\&\#39;))} + $output =~ s{(Bug reassigned from package (?:[\`']|\&\#39;))([^']+?)((?:'|\&\#39;) to (?:[\`']|\&\#39;))([^']+?)((?:'|\&\#39;))} {$1.q($2).$3.q($4).$5}eo; if (defined $time) { $output .= ' ('.strftime('%a, %d %b %Y %T GMT',gmtime($time)).') '; @@ -432,8 +442,21 @@ sub handle_record{ options => {msg=>$msg_number, mbox=>'yes'} ) - ) .'">mbox)'.":

\n"; - $output .= handle_email_message($record->{text}, + ) .'">mbox, '; + my $parser = MIME::Parser->new(); + # Because we are using memory, not tempfiles, there's no need to + # clean up here like in Debbugs::MIME + $parser->tmp_to_core(1); + $parser->output_to_core(1); + my $entity = $parser->parse_data($record->{text}); + my $r_l = reply_headers($entity); + $output .= q(reply); + + $output .= ')'.":

\n"; + $output .= handle_email_message($entity, ref => $bug_number, msg_num => $msg_number, %param, @@ -451,8 +474,8 @@ sub __libravatar_url { 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}//''); + ($email) = grep {/\@/} get_addresses($email); + return $config{libravatar_uri}.uri_escape_utf8($email.($config{libravatar_uri_options}//'')); }