summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorNiko Tyni <ntyni@debian.org>2016-04-25 16:31:00 +0300
committerAaron Crane <arc@cpan.org>2016-05-16 13:31:40 +0100
commitc04bead1edb16804f93c1d95979abf8e7477363a (patch)
tree378526285dec60164a3fdb5d26ffd69fec36f68c /utils
parentbd18aea6d95681e1bd5c2cdfd894bd3706e4b819 (diff)
downloadperl-c04bead1edb16804f93c1d95979abf8e7477363a.tar.gz
perlbug: wrap overly long lines
Mail transport agents limit the length of message lines at SMTP time. One observed limit is 1000 characters per line. Mail user agents typically work around these limits by MIME-encoding the message. Since perlbug doesn't do that, it needs to limit the length of its lines manually to make sure bug reports get delivered. The longest lines in perlbug reports normally come from Config::myconfig output, particularly 'config_args', which has been observed to exceed 1000 characters on some configurations, causing report rejection. While less likely, the list of local patches is another potential source of overly long lines. Use Text::Wrap (if available) to wrap the body of the report at an arbitrarily chosen and hopefully safe limit of 900 characters. No indentation or continuation line markers are added, though it would be easy to add those if desired. Attachments and mail headers are not wrapped. Bug-Debian: https://bugs.debian.org/822463
Diffstat (limited to 'utils')
-rw-r--r--utils/perlbug.PL13
1 files changed, 12 insertions, 1 deletions
diff --git a/utils/perlbug.PL b/utils/perlbug.PL
index 95e34fe051..6290ca76e8 100644
--- a/utils/perlbug.PL
+++ b/utils/perlbug.PL
@@ -76,6 +76,8 @@ BEGIN {
$::HaveTemp = ($@ eq "");
eval { require Module::CoreList; };
$::HaveCoreList = ($@ eq "");
+ eval { require Text::Wrap; };
+ $::HaveWrap = ($@ eq "");
};
my $Version = "1.40";
@@ -1084,7 +1086,16 @@ sub _read_report {
my $content;
open( REP, "<:raw", $fname ) or die "Couldn't open file '$fname': $!\n";
binmode(REP, ':raw :crlf') if $Is_MSWin32;
- while (<REP>) { $content .= $_; }
+ # wrap long lines to make sure the report gets delivered
+ local $Text::Wrap::columns = 900;
+ local $Text::Wrap::huge = 'overflow';
+ while (<REP>) {
+ if ($::HaveWrap && /\S/) { # wrap() would remove empty lines
+ $content .= Text::Wrap::wrap(undef, undef, $_);
+ } else {
+ $content .= $_;
+ }
+ }
close(REP) or die "Error closing report file '$fname': $!";
return $content;
}