From 8e7c683909967245600226f5863ba95c9318ec4d Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Wed, 28 Jun 2017 16:36:16 -0700 Subject: [PATCH] try to forcibly wrap messages which have not been properly wrapped --- Debbugs/CGI/Bugreport.pm | 15 ++++++++++++++- html/bugs.css | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Debbugs/CGI/Bugreport.pm b/Debbugs/CGI/Bugreport.pm index fb0ec9c..7dc2e5f 100644 --- a/Debbugs/CGI/Bugreport.pm +++ b/Debbugs/CGI/Bugreport.pm @@ -262,11 +262,24 @@ sub display_entity { 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; @@ -292,7 +305,7 @@ sub display_entity { {$1$2$3}gxm; } if (not exists $param{att}) { - print {$output} qq(
$body
\n); + print {$output} qq(
$body
\n); } } return 0; diff --git a/html/bugs.css b/html/bugs.css index 9019b9d..2b3ac57 100644 --- a/html/bugs.css +++ b/html/bugs.css @@ -102,6 +102,11 @@ pre.message { padding-top: 8px; margin-top: 0; border-top: 0; + white-space: pre-wrap; +} + +pre.wrapping { + width: 80ch; } .sparse li { -- 2.39.2