$::HaveCoreList = ($@ eq "");
};
-my $Version = "1.39";
+my $Version = "1.40";
#TODO:
# make sure failure (transmission-wise) of Mail::Send is accounted for.
$fh, $me, $body, $andcc, %REP, $ok, $thanks, $progname,
$Is_MSWin32, $Is_Linux, $Is_VMS, $Is_OpenBSD,
$report_about_module, $category, $severity,
- %opt,
+ %opt, $have_attachment, $attachments, $has_patch, $mime_boundary
);
my $perl_version = $^V ? sprintf("%vd", $^V) : $];
$Is_Linux = lc($^O) eq 'linux';
$Is_OpenBSD = lc($^O) eq 'openbsd';
- if (!getopts("Adhva:s:b:f:F:r:e:SCc:to:n:T", \%opt)) { Help(); exit; };
+ if (!getopts("Adhva:s:b:f:F:r:e:SCc:to:n:T:p:", \%opt)) { Help(); exit; };
# This comment is needed to notify metaconfig that we are
# using the $perladmin, $cf_by, and $cf_time definitions.
# File to send as report
$file = $opt{f} || "";
+ # We have one or more attachments
+ $have_attachment = ($opt{p} || 0);
+ $mime_boundary = ('-' x 12) . "$Version.perlbug" if $have_attachment;
+
+ # Comma-separated list of attachments
+ $attachments = $opt{p} || "";
+ $has_patch = 0; # TBD based on file type
+
+ for my $attachment (split /\s*,\s*/, $attachments) {
+ unless (-f $attachment && -r $attachment) {
+ die "The attachment $attachment is not a readable file: $!\n";
+ }
+ $has_patch = 1 if $attachment =~ m/\.(patch|diff)$/;
+ }
+
# File to output to
$outfile = $opt{F} || "";
}
} while (TrivialSubject($subject));
}
+ $subject = '[PATCH] ' . $subject
+ if $has_patch && ($subject !~ m/^\[PATCH/i);
# Prompt for return address, if needed
unless ($opt{r}) {
}
# Generate report
- open(REP,">$filename") or die "Unable to create report file '$filename': $!\n";
+ open(REP, '>:raw', $filename) or die "Unable to create report file '$filename': $!\n";
+ binmode(REP, ':raw :crlf') if $Is_MSWin32;
+
my $reptype = !$ok ? ($thanks ? 'thank-you' : 'bug')
: $opt{n} ? "build failure" : "success";
if ($body) {
print REP $body;
} elsif ($usefile) {
- open(F, "<$file")
+ open(F, '<:raw', $file)
or die "Unable to read report file from '$file': $!\n";
+ binmode(F, ':raw :crlf') if $Is_MSWin32;
while (<F>) {
print REP $_
}
severity=$severity
EFF
+ if ($has_patch) {
+ print OUT <<EFF;
+ Type=Patch
+ PatchStatus=HasPatch
+EFF
+ }
+
if ($report_about_module ) {
print OUT <<EFF;
module=$report_about_module
if ( SaveMessage() ) { exit }
} elsif ($action =~ /^(d|l|sh)/i ) { # <D>isplay, <L>ist, <Sh>ow
# Display the message
- open(REP, "<$filename") or die "Couldn't open file '$filename': $!\n";
+ open(REP, '<:raw', $filename) or die "Couldn't open file '$filename': $!\n";
+ binmode(REP, ':raw :crlf') if $Is_MSWin32;
while (<REP>) { print $_ }
close(REP) or die "Error closing report file '$filename': $!";
+ if ($have_attachment) {
+ print "\n\n---\nAttachment(s):\n";
+ for my $att (split /\s*,\s*/, $attachments) { print " $att\n"; }
+ }
} elsif ($action =~ /^su/i) { # <Su>bject
my $reply = _prompt( "Subject: $subject", "If the above subject is fine, press Enter. Otherwise, type a replacement now\nSubject");
if ($reply ne '') {
$0 [-v] [-a address] [-s subject] [-b body | -f inpufile ] [ -F outputfile ]
[-r returnaddress] [-e editor] [-c adminaddress | -C] [-S] [-t] [-h]
+ [-p patchfile ]
$0 [-v] [-r returnaddress] [-A] [-ok | -okay | -nok | -nokay]
-v Include Verbose configuration data in the report
-f File containing the body of the report. Use this to
quickly send a prepared message.
+ -p File containing a patch or other text attachment. Separate
+ multiple files with commas.
-F File to output the resulting mail message to, instead of mailing.
-S Send without asking for confirmation.
-a Address to send the report to. Defaults to '$address'.
$headers{'Message-Id'} = $messageid if ($messageid);
$headers{'Reply-To'} = $from if ($from);
$headers{'From'} = $from if ($from);
+ if ($have_attachment) {
+ $headers{'MIME-Version'} = '1.0';
+ $headers{'Content-Type'} = qq{multipart/mixed; boundary=\"$mime_boundary\"};
+ }
return \%headers;
}
+sub _add_body_start {
+ my $body_start = <<"BODY_START";
+This is a multi-part message in MIME format.
+--$mime_boundary
+Content-Type: text/plain; format=fixed
+Content-Transfer-Encoding: 8bit
+
+BODY_START
+ return $body_start;
+}
+
+sub _add_attachments {
+ my $attach = '';
+ for my $attachment (split /\s*,\s*/, $attachments) {
+ my $attach_file = basename($attachment);
+ $attach .= <<"ATTACHMENT";
+
+--$mime_boundary
+Content-Type: text/x-patch; name="$attach_file"
+Content-Transfer-Encoding: 8bit
+Content-Disposition: attachment; filename="$attach_file"
+
+ATTACHMENT
+
+ open my $attach_fh, '<:raw', $attachment
+ or die "Couldn't open attachment '$attachment': $!\n";
+ while (<$attach_fh>) { $attach .= $_; }
+ close($attach_fh) or die "Error closing attachment '$attachment': $!";
+ }
+
+ $attach .= "\n--$mime_boundary--\n";
+ return $attach;
+}
+
sub build_complete_message {
my $content = _build_header(%{_message_headers()}) . "\n\n";
- open( REP, "<$filename" ) or die "Couldn't open file '$filename': $!\n";
+ $content .= _add_body_start() if $have_attachment;
+ open( REP, "<:raw", $filename ) or die "Couldn't open file '$filename': $!\n";
+ binmode(REP, ':raw :crlf') if $Is_MSWin32;
while (<REP>) { $content .= $_; }
close(REP) or die "Error closing report file '$filename': $!";
+ $content .= _add_attachments() if $have_attachment;
return $content;
}
sub save_message_to_disk {
my $file = shift;
- open OUTFILE, ">$file" or do { warn "Couldn't open '$file': $!\n"; return undef};
+ open OUTFILE, '>:raw', $file or do { warn "Couldn't open '$file': $!\n"; return undef};
+ binmode(OUTFILE, ':raw :crlf') if $Is_MSWin32;
+
print OUTFILE build_complete_message();
close(OUTFILE) or do { warn "Error closing $file: $!"; return undef };
print "\nMessage saved.\n";
}
sub _send_message_vms {
- if ( ( $address =~ /@/ and $address !~ /^\w+%"/ )
- or ( $cc =~ /@/ and $cc !~ /^\w+%"/ ) ) {
- my $prefix;
- foreach ( qw[ IN MX SMTP UCX PONY WINS ], '' ) {
- $prefix = "$_%", last if $ENV{"MAIL\$PROTOCOL_$_"};
+
+ my $mail_from = $from;
+ my $rcpt_to_to = $address;
+ my $rcpt_to_cc = $cc;
+
+ map { $_ =~ s/^[^<]*<//;
+ $_ =~ s/>[^>]*//; } ($mail_from, $rcpt_to_to, $rcpt_to_cc);
+
+ if ( open my $sff_fh, '|-:raw', 'MCR TCPIP$SYSTEM:TCPIP$SMTP_SFF.EXE SYS$INPUT:' ) {
+ print $sff_fh "MAIL FROM:<$mail_from>\n";
+ print $sff_fh "RCPT TO:<$rcpt_to_to>\n";
+ print $sff_fh "RCPT TO:<$rcpt_to_cc>\n" if $rcpt_to_cc;
+ print $sff_fh "DATA\n";
+ print $sff_fh build_complete_message();
+ my $success = close $sff_fh;
+ if ($success ) {
+ print "\nMessage sent\n";
+ return;
}
- $address = qq[${prefix}"$address"] unless $address =~ /^\w+%"/;
- $cc = qq[${prefix}"$cc"] unless !$cc || $cc =~ /^\w+%"/;
- }
- $subject =~ s/"/""/g;
- $address =~ s/"/""/g;
- $cc =~ s/"/""/g;
- my $sts = system(qq[mail/Subject="$subject" $filename. "$address","$cc"]);
- if ($sts) {
- die "Can't spawn off mail (leaving bug report in $filename): $sts";
}
+ die "Mail transport failed (leaving bug report in $filename): $^E\n";
}
sub _send_message_mailsend {
}
$fh = $msg->open;
- open(REP, "<$filename") or die "Couldn't open '$filename': $!\n";
+ binmode($fh, ':raw');
+ print $fh _add_body_start() if $have_attachment;
+ open(REP, "<:raw", $filename) or die "Couldn't open '$filename': $!\n";
+ binmode(REP, ':raw :crlf') if $Is_MSWin32;
while (<REP>) { print $fh $_ }
close(REP) or die "Error closing $filename: $!";
+ print $fh _add_attachments() if $have_attachment;
$fh->close or die "Error sending mail: $!";
print "\nMessage sent.\n";
EOF
}
- open( SENDMAIL, "|-", $sendmail, "-t", "-oi", "-f", $from )
+ open( SENDMAIL, "|-:raw", $sendmail, "-t", "-oi", "-f", $from )
|| die "'|$sendmail -t -oi -f $from' failed: $!";
print SENDMAIL build_complete_message();
if ( close(SENDMAIL) ) {
# we can track whether the user does any editing.
# yes, *all* whitespace is ignored.
- open(REP, "<$filename") or die "Unable to open report file '$filename': $!\n";
+ open(REP, '<:raw', $filename) or die "Unable to open report file '$filename': $!\n";
+ binmode(REP, ':raw :crlf') if $Is_MSWin32;
while (my $line = <REP>) {
$line =~ s/\s+//g;
$new_lines++ if (!$REP{$line});
=item Can you fix the bug yourself?
-A bug report which I<includes a patch to fix it> will almost
-definitely be fixed. When sending a patch, please use the C<diff>
-program with the C<-u> option to generate "unified" diff files.
-Bug reports with patches are likely to receive significantly more
-attention and interest than those without patches.
+If so, that's great news; bug reports with patches are likely to
+receive significantly more attention and interest than those without
+patches. Please attach your patch to the report using the C<-p> option.
+When sending a patch, create it using C<git format-patch> if possible,
+though a unified diff created with C<diff -pu> will do nearly as well.
Your patch may be returned with requests for changes, or requests for more
detailed explanations about your fix.
Make sure the patch is not reversed (the first argument to diff is
typically the original file, the second argument your changed file).
-Make sure you test your patch by applying it with the C<patch>
-program before you send it on its way. Try to follow the same style
-as the code you are trying to patch. Make sure your patch really
-does work (C<make test>, if the thing you're patching is covered
+Make sure you test your patch by applying it with C<git am> or the
+C<patch> program before you send it on its way. Try to follow the
+same style as the code you are trying to patch. Make sure your patch
+really does work (C<make test>, if the thing you're patching is covered
by Perl's test suite).
=item Can you use C<perlbug> to submit the report?
As B<-nok> except it will report on older systems.
+=item B<-p>
+
+The names of one or more patch files or other text attachments to be
+included with the report. Multiple files must be separated with commas.
+
=item B<-r>
Your return address. The program will ask you to confirm its default
(E<lt>domo@computer.orgE<gt>), Hugo van der Sanden (E<lt>hv@crypt.orgE<gt>),
Jarkko Hietaniemi (E<lt>jhi@iki.fiE<gt>), Chris Nandor
(E<lt>pudge@pobox.comE<gt>), Jon Orwant (E<lt>orwant@media.mit.eduE<gt>,
-Richard Foley (E<lt>richard.foley@rfi.netE<gt>), and Jesse Vincent
-(E<lt>jesse@bestpractical.comE<gt>).
+Richard Foley (E<lt>richard.foley@rfi.netE<gt>), Jesse Vincent
+(E<lt>jesse@bestpractical.comE<gt>), and Craig A. Berry (E<lt>craigberry@mac.comE<gt>).
=head1 SEE ALSO