Bug 293907: remove tabs from bug_email.pl - Patch by Fr�d�ric Buclin <LpSolit@gmail.com> r=kiko a=justdave

This commit is contained in:
lpsolit%gmail.com 2005-05-12 17:26:26 +00:00
Родитель 8ecf38d2eb
Коммит ea9820c0e7
1 изменённых файлов: 211 добавлений и 211 удалений

Просмотреть файл

@ -38,7 +38,7 @@
# #
# You need to work with bug_email.pl the MIME::Parser installed. # You need to work with bug_email.pl the MIME::Parser installed.
# #
# $Id: bug_email.pl,v 1.25 2005-02-24 23:42:48 mkanat%kerio.com Exp $ # $Id: bug_email.pl,v 1.26 2005-05-12 17:26:26 lpsolit%gmail.com Exp $
############################################################### ###############################################################
# 02/12/2000 (SML) # 02/12/2000 (SML)
@ -135,41 +135,41 @@ sub storeAttachments( $$ )
$submitter_id ||= 0; $submitter_id ||= 0;
foreach my $pairref ( @$listref ) { foreach my $pairref ( @$listref ) {
my ($decoded_file, $mime, $on_disk, $description) = @$pairref; my ($decoded_file, $mime, $on_disk, $description) = @$pairref;
# Size check - mysql has a maximum space for the data ? # Size check - mysql has a maximum space for the data ?
$maxsize = 1047552; # should be queried by a system( "mysqld --help" );, $maxsize = 1047552; # should be queried by a system( "mysqld --help" );,
# but this seems not to be supported by all current mysql-versions # but this seems not to be supported by all current mysql-versions
# Read data file binary # Read data file binary
if( $on_disk ) { if( $on_disk ) {
if( open( FILE, "$decoded_file" )) { if( open( FILE, "$decoded_file" )) {
binmode FILE; binmode FILE;
read FILE, $data, $maxsize; read FILE, $data, $maxsize;
close FILE; close FILE;
$att_count ++; $att_count ++;
} else { } else {
print "Error while reading attachment $decoded_file!\n"; print "Error while reading attachment $decoded_file!\n";
next; next;
} }
# print "unlinking $datadir/mimedump-tmp/$decoded_file"; # print "unlinking $datadir/mimedump-tmp/$decoded_file";
# unlink "$datadir/mimedump-tmp/$decoded_file"; # unlink "$datadir/mimedump-tmp/$decoded_file";
} else { } else {
# data is in the scalar # data is in the scalar
$data = $decoded_file; $data = $decoded_file;
} }
# Make SQL-String # Make SQL-String
my $sql = "insert into attachments (bug_id, creation_ts, description, mimetype, ispatch, filename, thedata, submitter_id) values ("; my $sql = "insert into attachments (bug_id, creation_ts, description, mimetype, ispatch, filename, thedata, submitter_id) values (";
$sql .= "$bugid, now(), " . SqlQuote( $description ) . ", "; $sql .= "$bugid, now(), " . SqlQuote( $description ) . ", ";
$sql .= SqlQuote( $mime ) . ", "; $sql .= SqlQuote( $mime ) . ", ";
$sql .= "0, "; $sql .= "0, ";
$sql .= SqlQuote( $decoded_file ) . ", "; $sql .= SqlQuote( $decoded_file ) . ", ";
$sql .= SqlQuote( $data ) . ", "; $sql .= SqlQuote( $data ) . ", ";
$sql .= "$submitter_id );"; $sql .= "$submitter_id );";
SendSQL( $sql ) unless( $test ); SendSQL( $sql ) unless( $test );
} }
return( $att_count ); return( $att_count );
@ -196,9 +196,9 @@ sub CheckPermissions {
# SendSQL("select login_name from profiles,groups where groups.name='$GroupName' and profiles.groupset & groups.bit = groups.bit and profiles.login_name=\'$Name\'"); # SendSQL("select login_name from profiles,groups where groups.name='$GroupName' and profiles.groupset & groups.bit = groups.bit and profiles.login_name=\'$Name\'");
# my $NewName = FetchOneColumn(); # my $NewName = FetchOneColumn();
# if ( $NewName eq $Name ) { # if ( $NewName eq $Name ) {
# return $Name; # return $Name;
# } else { # } else {
# return; # return;
# } # }
# my $query = "SELECT login_name FROM profiles WHERE profiles.login_name=\'$Name\'"; # my $query = "SELECT login_name FROM profiles WHERE profiles.login_name=\'$Name\'";
# SendSQL($query); # SendSQL($query);
@ -219,9 +219,9 @@ sub CheckProduct {
SendSQL("select name from products where name = " . SqlQuote($Product)); SendSQL("select name from products where name = " . SqlQuote($Product));
my $Result = FetchOneColumn(); my $Result = FetchOneColumn();
if (lc($Result) eq lc($Product)) { if (lc($Result) eq lc($Product)) {
return $Result; return $Result;
} else { } else {
return ""; return "";
} }
} }
@ -234,9 +234,9 @@ sub CheckComponent {
SendSQL("select components.name from components, products where components.product_id = products.id AND products.name=" . SqlQuote($Product) . " and components.name=" . SqlQuote($Component)); SendSQL("select components.name from components, products where components.product_id = products.id AND products.name=" . SqlQuote($Product) . " and components.name=" . SqlQuote($Component));
my $Result = FetchOneColumn(); my $Result = FetchOneColumn();
if (lc($Result) eq lc($Component)) { if (lc($Result) eq lc($Component)) {
return $Result; return $Result;
} else { } else {
return ""; return "";
} }
} }
@ -249,9 +249,9 @@ sub CheckVersion {
SendSQL("select value from versions, products where versions.product_id = products.id AND products.name=" . SqlQuote($Product) . " and value=" . SqlQuote($Version)); SendSQL("select value from versions, products where versions.product_id = products.id AND products.name=" . SqlQuote($Product) . " and value=" . SqlQuote($Version));
my $Result = FetchOneColumn(); my $Result = FetchOneColumn();
if (lc($Result) eq lc($Version)) { if (lc($Result) eq lc($Version)) {
return $Result; return $Result;
} else { } else {
return ""; return "";
} }
} }
@ -264,10 +264,10 @@ sub Reply( $$$$ ) {
die "Cannot find sender-email-address" unless defined( $Sender ); die "Cannot find sender-email-address" unless defined( $Sender );
if( $test ) { if( $test ) {
open( MAIL, '>>', "$datadir/bug_email_test.log" ); open( MAIL, '>>', "$datadir/bug_email_test.log" );
} }
else { else {
open( MAIL, "| /usr/sbin/sendmail -t" ); open( MAIL, "| /usr/sbin/sendmail -t" );
} }
print MAIL "To: $Sender\n"; print MAIL "To: $Sender\n";
@ -311,18 +311,18 @@ sub CheckPriority
my @all_prios = getEnumList( "priority" ); my @all_prios = getEnumList( "priority" );
if( $prio eq "" || (lsearch( \@all_prios, $prio ) == -1) ) { if( $prio eq "" || (lsearch( \@all_prios, $prio ) == -1) ) {
# OK, Prio was not defined - create Answer # OK, Prio was not defined - create Answer
my $Text = "You sent wrong priority-setting, valid values are:" . my $Text = "You sent wrong priority-setting, valid values are:" .
join( "\n\t", @all_prios ) . "\n\n"; join( "\n\t", @all_prios ) . "\n\n";
$Text .= "* The priority is set to the default value ". $Text .= "* The priority is set to the default value ".
SqlQuote( Param('defaultpriority')) . "\n"; SqlQuote( Param('defaultpriority')) . "\n";
BugMailError( 0, $Text ); BugMailError( 0, $Text );
# set default value from param-file # set default value from param-file
$Control{'priority'} = Param( 'defaultpriority' ); $Control{'priority'} = Param( 'defaultpriority' );
} else { } else {
# Nothing to do # Nothing to do
} }
} }
@ -335,16 +335,16 @@ sub CheckSeverity
my @all_sever = getEnumList( "bug_severity" ); my @all_sever = getEnumList( "bug_severity" );
if( (lsearch( \@all_sever, $sever ) == -1) || $sever eq "" ) { if( (lsearch( \@all_sever, $sever ) == -1) || $sever eq "" ) {
# OK, Prio was not defined - create Answer # OK, Prio was not defined - create Answer
my $Text = "You sent wrong bug_severity-setting, valid values are:" . my $Text = "You sent wrong bug_severity-setting, valid values are:" .
join( "\n\t", @all_sever ) . "\n\n"; join( "\n\t", @all_sever ) . "\n\n";
$Text .= "* The bug_severity is set to the default value ". $Text .= "* The bug_severity is set to the default value ".
SqlQuote( "normal" ) . "\n"; SqlQuote( "normal" ) . "\n";
BugMailError( 0, $Text ); BugMailError( 0, $Text );
# set default value from param-file # set default value from param-file
$Control{'bug_severity'} = "normal"; $Control{'bug_severity'} = "normal";
} }
} }
@ -357,16 +357,16 @@ sub CheckArea
my @all= getEnumList( "area" ); my @all= getEnumList( "area" );
if( (lsearch( \@all, $area ) == -1) || $area eq "" ) { if( (lsearch( \@all, $area ) == -1) || $area eq "" ) {
# OK, Area was not defined - create Answer # OK, Area was not defined - create Answer
my $Text = "You sent wrong area-setting, valid values are:" . my $Text = "You sent wrong area-setting, valid values are:" .
join( "\n\t", @all ) . "\n\n"; join( "\n\t", @all ) . "\n\n";
$Text .= "* The area is set to the default value ". $Text .= "* The area is set to the default value ".
SqlQuote( "BUILD" ) . "\n"; SqlQuote( "BUILD" ) . "\n";
BugMailError( 0, $Text ); BugMailError( 0, $Text );
# set default value from param-file # set default value from param-file
$Control{'area'} = "BUILD"; $Control{'area'} = "BUILD";
} }
} }
@ -379,16 +379,16 @@ sub CheckPlatform
my @all = getEnumList( "rep_platform" ); my @all = getEnumList( "rep_platform" );
if( (lsearch( \@all, $platform ) == -1) || $platform eq "" ) { if( (lsearch( \@all, $platform ) == -1) || $platform eq "" ) {
# OK, Prio was not defined - create Answer # OK, Prio was not defined - create Answer
my $Text = "You sent wrong platform-setting, valid values are:" . my $Text = "You sent wrong platform-setting, valid values are:" .
join( "\n\t", @all ) . "\n\n"; join( "\n\t", @all ) . "\n\n";
$Text .= "* The rep_platform is set to the default value ". $Text .= "* The rep_platform is set to the default value ".
SqlQuote( "All" ) . "\n"; SqlQuote( "All" ) . "\n";
BugMailError( 0, $Text ); BugMailError( 0, $Text );
# set default value from param-file # set default value from param-file
$Control{'rep_platform'} = "All"; $Control{'rep_platform'} = "All";
} }
} }
@ -401,16 +401,16 @@ sub CheckSystem
my @all = getEnumList( "op_sys" ); my @all = getEnumList( "op_sys" );
if( (lsearch( \@all, $sys ) == -1) || $sys eq "" ) { if( (lsearch( \@all, $sys ) == -1) || $sys eq "" ) {
# OK, Prio was not defined - create Answer # OK, Prio was not defined - create Answer
my $Text = "You sent wrong OS-setting, valid values are:" . my $Text = "You sent wrong OS-setting, valid values are:" .
join( "\n\t", @all ) . "\n\n"; join( "\n\t", @all ) . "\n\n";
$Text .= "* The op_sys is set to the default value ". $Text .= "* The op_sys is set to the default value ".
SqlQuote( "Linux" ) . "\n"; SqlQuote( "Linux" ) . "\n";
BugMailError( 0, $Text ); BugMailError( 0, $Text );
# set default value from param-file # set default value from param-file
$Control{'op_sys'} = "Linux"; $Control{'op_sys'} = "Linux";
} }
} }
@ -424,7 +424,7 @@ sub FetchAllSQLData( )
my @res = (); my @res = ();
while( MoreSQLData() ){ while( MoreSQLData() ){
push( @res, FetchOneColumn() ); push( @res, FetchOneColumn() );
} }
return( @res ); return( @res );
} }
@ -463,21 +463,21 @@ sub BugMailError($ $ )
# On permission error, dont sent all other Errors back -> just quit ! # On permission error, dont sent all other Errors back -> just quit !
if( $errflag == 2 ) { # Permission-Error if( $errflag == 2 ) { # Permission-Error
Reply( $SenderShort, $Message_ID, "Bugzilla Error", "Permission denied.\n\n" . Reply( $SenderShort, $Message_ID, "Bugzilla Error", "Permission denied.\n\n" .
"You do not have the permissions to create a new bug. Sorry.\n" ); "You do not have the permissions to create a new bug. Sorry.\n" );
exit; exit;
} }
# Warnings - store for the reply mail # Warnings - store for the reply mail
if( $errflag == 0 ) { if( $errflag == 0 ) {
push( @mailwarnings, $text ); push( @mailwarnings, $text );
} }
# Critical Error # Critical Error
if( $errflag == 1 ) { if( $errflag == 1 ) {
$critical_err += 1; $critical_err += 1;
push( @mailerrors, $text ); push( @mailerrors, $text );
} }
} }
@ -546,19 +546,19 @@ _____ snip _____________________________________________________________________
EOF EOF
; ;
foreach ( @RequiredLabels ) { foreach ( @RequiredLabels ) {
$w = ""; $w = "";
$w = $Control{$_} if defined( $Control{ $_ } ); $w = $Control{$_} if defined( $Control{ $_ } );
$ret .= sprintf( " \@%-15s: %s\n", $_, $w ); $ret .= sprintf( " \@%-15s: %s\n", $_, $w );
} }
$ret .= "\n"; $ret .= "\n";
# Allowed Labels # Allowed Labels
foreach( @AllowedLabels ) { foreach( @AllowedLabels ) {
next if( /reporter/ ); # Reporter is not a valid label next if( /reporter/ ); # Reporter is not a valid label
next if( /assigned_to/ ); # Assigned to is just a number next if( /assigned_to/ ); # Assigned to is just a number
if( defined( $Control{ $_ } ) && lsearch( \@RequiredLabels, $_ ) == -1 ) { if( defined( $Control{ $_ } ) && lsearch( \@RequiredLabels, $_ ) == -1 ) {
$ret .= sprintf( " \@%-15s: %s\n", $_, $Control{ $_ } ); $ret .= sprintf( " \@%-15s: %s\n", $_, $Control{ $_ } );
} }
} }
if( $Body eq "" ) { if( $Body eq "" ) {
@ -570,7 +570,7 @@ _____ snip _____________________________________________________________________
END END
; } else { ; } else {
$ret .= "\n" . $Body; $ret .= "\n" . $Body;
} }
return( $ret ); return( $ret );
@ -597,47 +597,47 @@ sub dump_entity {
# Output the body: # Output the body:
my @parts = $entity->parts; my @parts = $entity->parts;
if (@parts) { # multipart... if (@parts) { # multipart...
my $i; my $i;
foreach $i (0 .. $#parts) { # dump each part... foreach $i (0 .. $#parts) { # dump each part...
dump_entity($parts[$i], ("$name, part ".(1+$i))); dump_entity($parts[$i], ("$name, part ".(1+$i)));
} }
} else { # single part... } else { # single part...
# Get MIME type, and display accordingly... # Get MIME type, and display accordingly...
my $msg_part = $entity->head->get( 'Content-Disposition' ); my $msg_part = $entity->head->get( 'Content-Disposition' );
$msg_part ||= ""; $msg_part ||= "";
my ($type, $subtype) = split('/', $entity->head->mime_type); my ($type, $subtype) = split('/', $entity->head->mime_type);
my $body = $entity->bodyhandle; my $body = $entity->bodyhandle;
my ($data, $on_disk ); my ($data, $on_disk );
if( $msg_part =~ /^attachment/ ) { if( $msg_part =~ /^attachment/ ) {
# Attached File # Attached File
my $des = $entity->head->get('Content-Description'); my $des = $entity->head->get('Content-Description');
$des ||= $entity->head->recommended_filename; $des ||= $entity->head->recommended_filename;
$des ||= "unnamed attachment"; $des ||= "unnamed attachment";
if( defined( $body->path )) { # Data is on disk if( defined( $body->path )) { # Data is on disk
$on_disk = 1; $on_disk = 1;
$data = $body->path; $data = $body->path;
} else { # Data is in core } else { # Data is in core
$on_disk = 0; $on_disk = 0;
$data = $body->as_string; $data = $body->as_string;
} }
push ( @attachments, [ $data, $entity->head->mime_type, $on_disk, $des ] ); push ( @attachments, [ $data, $entity->head->mime_type, $on_disk, $des ] );
} else { } else {
# Real Message # Real Message
if ($type =~ /^(text|message)$/) { # text: display it... if ($type =~ /^(text|message)$/) { # text: display it...
if ($IO = $body->open("r")) { if ($IO = $body->open("r")) {
$Body .= $_ while (defined($_ = $IO->getline)); $Body .= $_ while (defined($_ = $IO->getline));
$IO->close; $IO->close;
} else { # d'oh! } else { # d'oh!
print "$0: couldn't find/open '$name': $!"; print "$0: couldn't find/open '$name': $!";
} }
} else { print "Oooops - no Body !\n"; } } else { print "Oooops - no Body !\n"; }
} }
} }
} }
@ -658,19 +658,19 @@ sub extractControls( $ )
# In restricted mode, all lines before the first keyword # In restricted mode, all lines before the first keyword
# are skipped. # are skipped.
if( $restricted ) { if( $restricted ) {
while( $lbody[0] =~ /^\s*\@.*/ ){ shift( @lbody );} while( $lbody[0] =~ /^\s*\@.*/ ){ shift( @lbody );}
} }
# Filtering for keys # Filtering for keys
foreach( @lbody ) { foreach( @lbody ) {
if( /^\s*\@description/ ) { if( /^\s*\@description/ ) {
s/\s*\@description//; s/\s*\@description//;
$backbody .= $_; $backbody .= $_;
} elsif( /^\s*\@(.*?)(?:\s*=\s*|\s*:\s*|\s+)(.*?)\s*$/ ) { } elsif( /^\s*\@(.*?)(?:\s*=\s*|\s*:\s*|\s+)(.*?)\s*$/ ) {
$Control{lc($1)} = $2; $Control{lc($1)} = $2;
} else { } else {
$backbody .= "$_" . "\n"; $backbody .= "$_" . "\n";
} }
} }
# thats it. # thats it.
@ -768,7 +768,7 @@ $Body = extractControls( $Body ); # fills the Control-Hash
if( $test ) { if( $test ) {
foreach (keys %Control ) { foreach (keys %Control ) {
print "$_ => $Control{$_}\n"; print "$_ => $Control{$_}\n";
} }
} }
@ -782,14 +782,14 @@ $Control{'short_desc'} ||= $Subject;
# Check Control-Labels # Check Control-Labels
# not: reporter ! # not: reporter !
@AllowedLabels = ("product", "version", "rep_platform", @AllowedLabels = ("product", "version", "rep_platform",
"bug_severity", "priority", "op_sys", "assigned_to", "bug_severity", "priority", "op_sys", "assigned_to",
"bug_status", "bug_file_loc", "short_desc", "component", "bug_status", "bug_file_loc", "short_desc", "component",
"status_whiteboard", "target_milestone", "groupset", "status_whiteboard", "target_milestone", "groupset",
"qa_contact"); "qa_contact");
#my @AllowedLabels = qw{Summary priority platform assign}; #my @AllowedLabels = qw{Summary priority platform assign};
foreach (keys %Control) { foreach (keys %Control) {
if ( lsearch( \@AllowedLabels, $_) < 0 ) { if ( lsearch( \@AllowedLabels, $_) < 0 ) {
BugMailError( 0, "You sent a unknown label: " . $_ ); BugMailError( 0, "You sent a unknown label: " . $_ );
} }
} }
@ -802,13 +802,13 @@ $Control{'reporter'} = $SenderShort;
@RequiredLabels = qw{product version component short_desc}; @RequiredLabels = qw{product version component short_desc};
foreach my $Label (@RequiredLabels) { foreach my $Label (@RequiredLabels) {
if ( ! defined $Control{$Label} ) { if ( ! defined $Control{$Label} ) {
BugMailError( 0, "You were missing a required label: \@$Label\n" ); BugMailError( 0, "You were missing a required label: \@$Label\n" );
next; next;
} }
if( $Control{$Label} =~ /^\s*$/ ) { if( $Control{$Label} =~ /^\s*$/ ) {
BugMailError( 0, "One of your required labels is empty: $Label" ); BugMailError( 0, "One of your required labels is empty: $Label" );
next; next;
} }
} }
@ -822,7 +822,7 @@ if ( $Body =~ /^\s*$/s ) {
# Check Permissions ... # Check Permissions ...
if (! CheckPermissions("CreateBugs", $SenderShort ) ) { if (! CheckPermissions("CreateBugs", $SenderShort ) ) {
BugMailError( 2, "Permission denied.\n\n" . BugMailError( 2, "Permission denied.\n\n" .
"You do not have the permissions to create a new bug. Sorry.\n" ); "You do not have the permissions to create a new bug. Sorry.\n" );
} }
# Set QA # Set QA
@ -846,7 +846,7 @@ if ( $Product eq "" ) {
my $Text = "You didnt send a value for the required key \@product !\n\n"; my $Text = "You didnt send a value for the required key \@product !\n\n";
$Text = "You sent the invalid product \"$Control{'product'}\"!\n\n" $Text = "You sent the invalid product \"$Control{'product'}\"!\n\n"
if( defined( $Control{ 'product'} )); if( defined( $Control{ 'product'} ));
$Text .= "Valid products are:\n\t"; $Text .= "Valid products are:\n\t";
@ -879,7 +879,7 @@ if ( $Component eq "" ) {
my $Text = "You did not send a value for the required key \@component!\n\n"; my $Text = "You did not send a value for the required key \@component!\n\n";
if( defined( $Control{ 'component' } )) { if( defined( $Control{ 'component' } )) {
$Text = "You sent the invalid component \"$Control{'component'}\" !\n"; $Text = "You sent the invalid component \"$Control{'component'}\" !\n";
} }
# #
@ -888,28 +888,28 @@ if ( $Component eq "" ) {
# if a product was sent, only reply the components of the sent product # if a product was sent, only reply the components of the sent product
my @val_components = (); my @val_components = ();
foreach my $prod ( @all_products ) { foreach my $prod ( @all_products ) {
$Text .= "\nValid components for product `$prod' are: \n\t"; $Text .= "\nValid components for product `$prod' are: \n\t";
SendSQL("SELECT components.name FROM components, products WHERE components.product_id=products.id AND products.name = " . SqlQuote($prod)); SendSQL("SELECT components.name FROM components, products WHERE components.product_id=products.id AND products.name = " . SqlQuote($prod));
@val_components = FetchAllSQLData(); @val_components = FetchAllSQLData();
$Text .= join( "\n\t", @val_components ) . "\n"; $Text .= join( "\n\t", @val_components ) . "\n";
} }
# Special: if there is a valid product, maybe it has only one component -> use it ! # Special: if there is a valid product, maybe it has only one component -> use it !
# #
my $amount_of_comps = @val_components; my $amount_of_comps = @val_components;
if( $product_valid && $amount_of_comps == 1 ) { if( $product_valid && $amount_of_comps == 1 ) {
$Component = $val_components[0]; $Component = $val_components[0];
$Text .= " * You did not send a component, but a valid product " . SqlQuote( $Product ) . ".\n"; $Text .= " * You did not send a component, but a valid product " . SqlQuote( $Product ) . ".\n";
$Text .= " * This product only has one component ". SqlQuote( $Component ) .".\n" . $Text .= " * This product only has one component ". SqlQuote( $Component ) .".\n" .
" * This component was set by bugzilla for submitting the bug.\n\n"; " * This component was set by bugzilla for submitting the bug.\n\n";
BugMailError( 0, $Text ); # No blocker BugMailError( 0, $Text ); # No blocker
} else { # The component is really buggy :( } else { # The component is really buggy :(
$Text .= horLine(); $Text .= horLine();
BugMailError( 1, $Text ); BugMailError( 1, $Text );
} }
} }
$Control{'component'} = $Component; $Control{'component'} = $Component;
@ -932,10 +932,10 @@ if ( defined($Control{'assigned_to'})
if ( $Control{'assigned_to'} == 0 ) { if ( $Control{'assigned_to'} == 0 ) {
my $Text = "Could not resolve key \@assigned_to !\n" . my $Text = "Could not resolve key \@assigned_to !\n" .
"If you do NOT send a value for assigned_to, the bug will be assigned to\n" . "If you do NOT send a value for assigned_to, the bug will be assigned to\n" .
"the qa-contact for the product and component.\n"; "the qa-contact for the product and component.\n";
$Text .= "This works only if product and component are OK. \n" $Text .= "This works only if product and component are OK. \n"
. horLine(); . horLine();
BugMailError( 1, $Text ); BugMailError( 1, $Text );
} }
@ -961,34 +961,34 @@ if ( $Version eq "" ) {
my $Text = "You did not send a value for the required key \@version!\n\n"; my $Text = "You did not send a value for the required key \@version!\n\n";
if( defined( $Control{'version'})) { if( defined( $Control{'version'})) {
my $Text = "You sent the invalid version \"$Control{'version'}\"!\n"; my $Text = "You sent the invalid version \"$Control{'version'}\"!\n";
} }
my $anz_versions; my $anz_versions;
my @all_versions; my @all_versions;
# Assemble help text # Assemble help text
foreach my $prod ( @all_products ) { foreach my $prod ( @all_products ) {
$Text .= "Valid versions for product " . SqlQuote( $prod ) . " are: \n\t"; $Text .= "Valid versions for product " . SqlQuote( $prod ) . " are: \n\t";
SendSQL("select value from versions, products where versions.product_id=products.id AND products.name=" . SqlQuote( $prod )); SendSQL("select value from versions, products where versions.product_id=products.id AND products.name=" . SqlQuote( $prod ));
@all_versions = FetchAllSQLData(); @all_versions = FetchAllSQLData();
$anz_versions = @all_versions; $anz_versions = @all_versions;
$Text .= join( "\n\t", @all_versions ) . "\n" ; $Text .= join( "\n\t", @all_versions ) . "\n" ;
} }
# Check if we could use the only version # Check if we could use the only version
if( $anz_versions == 1 && $product_valid ) { if( $anz_versions == 1 && $product_valid ) {
$Version = $all_versions[0]; $Version = $all_versions[0];
# Fine, there is only one version string # Fine, there is only one version string
$Text .= " * You did not send a version, but a valid product " . SqlQuote( $Product ) . ".\n"; $Text .= " * You did not send a version, but a valid product " . SqlQuote( $Product ) . ".\n";
$Text .= " * This product has has only the one version ". SqlQuote( $Version) .".\n" . $Text .= " * This product has has only the one version ". SqlQuote( $Version) .".\n" .
" * This version was set by bugzilla for submitting the bug.\n\n"; " * This version was set by bugzilla for submitting the bug.\n\n";
$Text .= horLine(); $Text .= horLine();
BugMailError( 0, $Text ); # No blocker BugMailError( 0, $Text ); # No blocker
} else { } else {
$Text .= horLine(); $Text .= horLine();
BugMailError( 1, $Text ); BugMailError( 1, $Text );
} }
} }
@ -1029,25 +1029,25 @@ if( $GroupSet eq "" ) {
# Then search for every Literal in the DB - col name # Then search for every Literal in the DB - col name
foreach ( split /\s+|\s*\+\s*|\s*,\s*/, $GroupSet ) { foreach ( split /\s+|\s*\+\s*|\s*,\s*/, $GroupSet ) {
SendSQL("select id, Name from groups where name=" . SqlQuote($_)); SendSQL("select id, Name from groups where name=" . SqlQuote($_));
my( $bval, $bname ) = FetchSQLData(); my( $bval, $bname ) = FetchSQLData();
if( defined( $bname ) && $_ eq $bname ) { if( defined( $bname ) && $_ eq $bname ) {
$GroupArr{$bname} = $bval; $GroupArr{$bname} = $bval;
} else { } else {
$Text .= "You sent the wrong GroupSet-String $_\n"; $Text .= "You sent the wrong GroupSet-String $_\n";
$gserr = 1; $gserr = 1;
} }
} }
# #
# Give help if wrong GroupSet-String came # Give help if wrong GroupSet-String came
if( $gserr > 0 ) { if( $gserr > 0 ) {
# There happend errors # There happend errors
$Text .= "Here are all valid literal Groupsetting-strings:\n\t"; $Text .= "Here are all valid literal Groupsetting-strings:\n\t";
SendSQL( "select g.name from groups g, user_group_map u where u.user_id=".$Control{'reporter'}. SendSQL( "select g.name from groups g, user_group_map u where u.user_id=".$Control{'reporter'}.
" and g.isbuggroup=1 and g.id = u.group_id group by g.name;" ); " and g.isbuggroup=1 and g.id = u.group_id group by g.name;" );
$Text .= join( "\n\t", FetchAllSQLData()) . "\n"; $Text .= join( "\n\t", FetchAllSQLData()) . "\n";
BugMailError( 0, $Text ); BugMailError( 0, $Text );
} }
} # End of checking groupsets } # End of checking groupsets
delete $Control{'groupset'}; delete $Control{'groupset'};
@ -1086,7 +1086,7 @@ END
my $reporter = ""; my $reporter = "";
my $query = "insert into bugs (\n" . join(",\n", @used_fields ) . my $query = "insert into bugs (\n" . join(",\n", @used_fields ) .
", bug_status, creation_ts, delta_ts, everconfirmed) values ( "; ", bug_status, creation_ts, delta_ts, everconfirmed) values ( ";
# 'Yuck'. Then again, this whole file should be rewritten anyway... # 'Yuck'. Then again, this whole file should be rewritten anyway...
$query =~ s/product/product_id/; $query =~ s/product/product_id/;
@ -1096,14 +1096,14 @@ END
my $val; my $val;
foreach my $field (@used_fields) { foreach my $field (@used_fields) {
if( $field eq "groupset" ) { if( $field eq "groupset" ) {
$query .= $Control{$field} . ",\n"; $query .= $Control{$field} . ",\n";
} elsif ( $field eq 'product' ) { } elsif ( $field eq 'product' ) {
$query .= get_product_id($Control{$field}) . ",\n"; $query .= get_product_id($Control{$field}) . ",\n";
} elsif ( $field eq 'component' ) { } elsif ( $field eq 'component' ) {
$query .= get_component_id(get_product_id($Control{'product'}), $query .= get_component_id(get_product_id($Control{'product'}),
$Control{$field}) . ",\n"; $Control{$field}) . ",\n";
} else { } else {
$query .= SqlQuote($Control{$field}) . ",\n"; $query .= SqlQuote($Control{$field}) . ",\n";
} }
$val = $Control{ $field }; $val = $Control{ $field };
@ -1113,7 +1113,7 @@ END
$tmp_reply .= sprintf( " \@%-15s = %-15s\n", $field, $val ); $tmp_reply .= sprintf( " \@%-15s = %-15s\n", $field, $val );
if ($field eq "reporter") { if ($field eq "reporter") {
$reporter = $val; $reporter = $val;
} }
} }
# #
@ -1150,19 +1150,19 @@ END
my $id; my $id;
if( ! $test ) { if( ! $test ) {
SendSQL($query); SendSQL($query);
$id = Bugzilla->dbh->bz_last_key('bugs', 'bug_id'); $id = Bugzilla->dbh->bz_last_key('bugs', 'bug_id');
my $long_desc_query = "INSERT INTO longdescs SET bug_id=$id, who=$userid, bug_when=\'$bug_when\', thetext=" . SqlQuote($comment); my $long_desc_query = "INSERT INTO longdescs SET bug_id=$id, who=$userid, bug_when=\'$bug_when\', thetext=" . SqlQuote($comment);
SendSQL($long_desc_query); SendSQL($long_desc_query);
# Cool, the mail was successful # Cool, the mail was successful
# system("./processmail", $id, $SenderShort); # system("./processmail", $id, $SenderShort);
} else { } else {
$id = 0xFFFFFFFF; # TEST ! $id = 0xFFFFFFFF; # TEST !
print "\n-------------------------------------------------------------------------\n"; print "\n-------------------------------------------------------------------------\n";
print "$query\n"; print "$query\n";
} }
# #