From c04bead1edb16804f93c1d95979abf8e7477363a Mon Sep 17 00:00:00 2001 From: Niko Tyni Date: Mon, 25 Apr 2016 16:31:00 +0300 Subject: 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 --- utils/perlbug.PL | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'utils') 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 () { $content .= $_; } + # wrap long lines to make sure the report gets delivered + local $Text::Wrap::columns = 900; + local $Text::Wrap::huge = 'overflow'; + while () { + 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; } -- cgit v1.2.1