Skip to content

Commit

Permalink
ensure SQL querys from FlagTypeComment are valid
Browse files Browse the repository at this point in the history
when $types is empty the SQL query is invalid
  • Loading branch information
Alexander Merkle authored and justdave committed Jul 4, 2023
1 parent 17a8057 commit 2d73fd6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions extensions/FlagTypeComment/Extension.pm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ sub _set_ftc_states {
my $dbh = Bugzilla->dbh;

my $ftc_flags;
my $db_result;
my $db_result = [];
if ($file =~ /^admin\//) {

# admin
Expand Down Expand Up @@ -121,11 +121,13 @@ sub _set_ftc_states {

my $types = join(',', map { $_->id } @$flag_types);
my $states = "'" . join("','", FLAGTYPE_COMMENT_STATES) . "'";
$db_result = $dbh->selectall_arrayref(
"SELECT type_id AS flagtype, on_status AS state, comment AS text
FROM flagtype_comments
WHERE type_id IN ($types) AND on_status IN ($states)", {Slice => {}}
);
if ($types) {
$db_result = $dbh->selectall_arrayref(
"SELECT type_id AS flagtype, on_status AS state, comment AS text
FROM flagtype_comments
WHERE type_id IN ($types) AND on_status IN ($states)", {Slice => {}}
);
}
}

foreach my $row (@$db_result) {
Expand Down

0 comments on commit 2d73fd6

Please sign in to comment.