use warnings;
use strict;
use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT);
-use base qw(Exporter);
+use Exporter qw(import);
use IO::Scalar;
use Params::Validate qw(validate_with :types);
my $output = globify_scalar($param{output});
my $entity = $param{entity};
my $ref = $param{bug_num};
- my $top = $param{outer};
my $xmessage = $param{msg_num};
my $attachments = $param{attachments};
my $body = $entity->bodyhandle->as_string;
$body = convert_to_utf8($body,$charset//'utf8');
$body = html_escape($body);
+ my $css_class = "message";
# Attempt to deal with format=flowed
if ($content_type =~ m/format\s*=\s*\"?flowed\"?/i) {
$body =~ s{^\ }{}mgo;
# we ignore the other things that you can do with
# flowed e-mails cause they don't really matter.
+ $css_class .= " flowed";
+ }
+
+ # if the message is composed entirely of lines which are separated by
+ # newlines, wrap it. [Allow the signature to have special formatting.]
+ if ($body =~ /^([^\n]+\n\n)*[^\n]*\n?(-- \n.+)*$/s or
+ # if the first 20 lines in the message which have any non-space
+ # characters are larger than 100 characters more often than they
+ # are not, then use CSS to try to impose sensible wrapping
+ sum0(map {length ($_) > 100?1:-1} grep {/\S/} split /\n/,$body,20) > 0
+ ) {
+ $css_class .= " wrapping";
}
# Add links to URLs
# We don't html escape here because we escape above;
{$1<a href="http://$config{cve_tracker}$2">$2</a>$3}gxm;
}
if (not exists $param{att}) {
- print {$output} qq(<pre class="message">$body</pre>\n);
+ print {$output} qq(<pre class="$css_class">$body</pre>\n);
}
}
return 0;
# $record->{text} is not in perl's internal encoding; convert it
my $text = decode_rfc1522(decode_utf8(record_text($record)));
my ($time) = $text =~ /<!--\s+time:(\d+)\s+-->/;
- my $class = $text =~ /^<strong>(?:Acknowledgement|Reply|Information|Report|Notification)/m ? 'infmessage':'msgreceived';
+ my $class = $text =~ /^<strong>(?:Acknowledgement|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)
{$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\sreassigned\sfrom\spackage\s(?:[\`']|\&\#39;))([^']+?)((?:'|\&\#39;|\"\;)
+ $output =~ s{($config{bug}\sreassigned\sfrom\spackage\s(?:[\`']|\&\#39;))([^']+?)((?:'|\&\#39;|\"\;)
\sto\s(?:[\`']|\&\#39;|\"\;))([^']+?)((?:'|\&\#39;|\"\;))}
- {$1.q(<a href=").html_escape(package_links(package=>$2)).qq(">$2</a>).$3.
- q(<a href=").html_escape(package_links(package=>$4)).qq(">$4</a>).$5}exo;
+ {$1.package_links(package=>$2).$3.
+ package_links(package=>$4).$5}exo;
if (defined $time) {
$output .= ' ('.strftime('%a, %d %b %Y %T GMT',gmtime($time)).') ';
}