X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FCGI%2FBugreport.pm;h=64211884e1ac47d1e41961d267361801be82d9eb;hb=d36378ccdad74171fab90161276d5837b4dda874;hp=67ed7ba9c6ba04a1b2a6703168f3982e98b5d552;hpb=9907f86ebd19706ce79b2b0cf2f54e8ae4112427;p=debbugs.git diff --git a/Debbugs/CGI/Bugreport.pm b/Debbugs/CGI/Bugreport.pm index 67ed7ba..6421188 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,7 +41,9 @@ 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); +use URI::Escape qw(uri_escape_utf8); +use Scalar::Util qw(blessed); +use File::Temp; BEGIN{ ($VERSION) = q$Revision: 494 $ =~ /^Revision:\s+([^\s+])/; @@ -138,9 +140,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($_); @@ -149,7 +150,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"; @@ -271,10 +272,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; @@ -283,7 +288,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}) { @@ -312,12 +317,18 @@ 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 + # this will be cleaned up once it goes out of scope + my $tempdir = File::Temp->newdir(); + $parser->output_under($tempdir->dirname()); + $entity = $parser->parse_data( $email); + } else { + $entity = $email + } my @attachments = (); my $raw_output = display_entity(entity => $entity, @@ -360,7 +371,8 @@ sub handle_record{ $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; + $output =~ s,((?:ftp|http|https)://[\S~-]+?/?)((?:[\)\'\:\.\,]|\&\#39;|\"\;)? + (?:\s|\.<|$)),$1$2,gxo; # Add links to the cloned bugs $output =~ s{(Bug )(\d+)( cloned as bugs? )(\d+)(?:\-(\d+)|)}{$1.bug_links(bug=>$2).$3.bug_links(bug=>(defined $5)?[$4..$5]:$4)}eo; # Add links to merged bugs @@ -377,8 +389,10 @@ 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;))} - {$1.q($2).$3.q($4).$5}eo; + $output =~ s{(Bug\sreassigned\sfrom\spackage\s(?:[\`']|\&\#39;))([^']+?)((?:'|\&\#39;|\"\;) + \sto\s(?:[\`']|\&\#39;|\"\;))([^']+?)((?:'|\&\#39;|\"\;))} + {$1.q($2).$3. + q($4).$5}exo; if (defined $time) { $output .= ' ('.strftime('%a, %d %b %Y %T GMT',gmtime($time)).') '; } @@ -433,8 +447,21 @@ sub handle_record{ options => {msg=>$msg_number, mbox=>'yes'} ) - ) .'">mbox)'.":

\n"; - $output .= handle_email_message($record->{text}, + ) .'">mbox, '; + my $parser = MIME::Parser->new(); + + # this will be cleaned up once it goes out of scope + my $tempdir = File::Temp->newdir(); + $parser->output_under($tempdir->dirname()); + 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, @@ -452,8 +479,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}.uri_escape($email.($config{libravatar_uri_options}//'')); + ($email) = grep {/\@/} get_addresses($email); + return $config{libravatar_uri}.uri_escape_utf8($email.($config{libravatar_uri_options}//'')); }