Skip to content

Commit

Permalink
Bug 1751601 - Bugzilla::User->visible_bugs causes fatal error if one …
Browse files Browse the repository at this point in the history
…of the bug ids passed is an alias and not a bug id
  • Loading branch information
dklawren committed Feb 1, 2022
1 parent c992fd7 commit 747271d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Bugzilla/Bug.pm
Expand Up @@ -4636,14 +4636,14 @@ sub GetBugActivity {
foreach my $value (split /, /, $removed) {
if (substr($value, 0, length $url_base) eq $url_base) {
my ($bug_id) = $value =~ /id=(\d+)$/;
next if !Bugzilla->user->can_see_bug($bug_id);
next if !$bug_id || !Bugzilla->user->can_see_bug($bug_id);
}
push @filtered_removed, $value;
}
foreach my $value (split /, /, $added) {
if (substr($value, 0, length $url_base) eq $url_base) {
my ($bug_id) = $value =~ /id=(\d+)$/;
next if !Bugzilla->user->can_see_bug($bug_id);
next if !$bug_id || !Bugzilla->user->can_see_bug($bug_id);
}
push @filtered_added, $value;
}
Expand Down
15 changes: 14 additions & 1 deletion Bugzilla/BugUrl/Bugzilla/Local.pm
Expand Up @@ -13,6 +13,7 @@ use warnings;

use base qw(Bugzilla::BugUrl::Bugzilla);

use Bugzilla::Bug qw(bug_alias_to_id);
use Bugzilla::Error;
use Bugzilla::Util;

Expand Down Expand Up @@ -73,7 +74,19 @@ sub _check_value {
$uri = $class->SUPER::_check_value($uri);
}

my $ref_bug_id = $uri->query_param('id');
# If bug ID is an alias, we want to store the value in the DB
# as the actual ID instead of the alias for visibility checking
# and other parts of the code.
my $ref_bug_id = $uri->query_param('id');
if ($ref_bug_id !~ /^\d+$/) {
my $orig_ref_bug_id = $ref_bug_id;
$ref_bug_id = bug_alias_to_id($ref_bug_id);
$ref_bug_id
|| ThrowUserError('improper_bug_id_field_value',
{bug_id => $orig_ref_bug_id});
$uri->query_param('id', $ref_bug_id);
}

my $ref_bug = Bugzilla::Bug->check($ref_bug_id);
my $self_bug_id = $params->{bug_id};
$params->{ref_bug} = $ref_bug;
Expand Down

0 comments on commit 747271d

Please sign in to comment.