Skip to content

Commit c04bead

Browse files
ntyniarc
authored andcommitted
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
1 parent bd18aea commit c04bead

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/perlbug.t

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,5 @@ for (split(/\n/, $contents)) {
151151
$maxlen1 = $len if $len > $maxlen1 and !/$B/;
152152
$maxlen2 = $len if $len > $maxlen2 and /$B/;
153153
}
154-
TODO: {
155-
local $::TODO = 'long body lines not wrapped yet';
156154
ok($maxlen1 < 1000, "[perl #128020] long body lines are wrapped: maxlen $maxlen1");
157-
}
158155
ok($maxlen2 > 1000, "long attachment lines are not wrapped: maxlen $maxlen2");

utils/perlbug.PL

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ BEGIN {
7676
$::HaveTemp = ($@ eq "");
7777
eval { require Module::CoreList; };
7878
$::HaveCoreList = ($@ eq "");
79+
eval { require Text::Wrap; };
80+
$::HaveWrap = ($@ eq "");
7981
};
8082
8183
my $Version = "1.40";
@@ -1084,7 +1086,16 @@ sub _read_report {
10841086
my $content;
10851087
open( REP, "<:raw", $fname ) or die "Couldn't open file '$fname': $!\n";
10861088
binmode(REP, ':raw :crlf') if $Is_MSWin32;
1087-
while (<REP>) { $content .= $_; }
1089+
# wrap long lines to make sure the report gets delivered
1090+
local $Text::Wrap::columns = 900;
1091+
local $Text::Wrap::huge = 'overflow';
1092+
while (<REP>) {
1093+
if ($::HaveWrap && /\S/) { # wrap() would remove empty lines
1094+
$content .= Text::Wrap::wrap(undef, undef, $_);
1095+
} else {
1096+
$content .= $_;
1097+
}
1098+
}
10881099
close(REP) or die "Error closing report file '$fname': $!";
10891100
return $content;
10901101
}

0 commit comments

Comments
 (0)