]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 788098: Queries involving group substitution crash when usevisibilitygroups is...
authorFrédéric Buclin <LpSolit@gmail.com>
Thu, 4 Oct 2012 15:48:23 +0000 (17:48 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Thu, 4 Oct 2012 15:48:23 +0000 (17:48 +0200)
r=dkl a=LpSolit

Bugzilla/Group.pm
Bugzilla/Search.pm

index b7532fe09380ec36f132cbb6e82e5fb0eaf993d9..382407748ef8ff519874d2e6196f674b938c8834 100644 (file)
@@ -189,7 +189,9 @@ sub check_members_are_visible {
     my $self = shift;
     my $user = Bugzilla->user;
     return if !Bugzilla->params->{'usevisibilitygroups'};
-    my $is_visible = grep { $_->id == $_ } @{ $user->visible_groups_inherited };
+
+    my $group_id = $self->id;
+    my $is_visible = grep { $_ == $group_id } @{ $user->visible_groups_inherited };
     if (!$is_visible) {
         ThrowUserError('group_not_visible', { group => $self });
     }
index 9a5e888bcd83e4b84589c4a19354ec664d8da847..f0e015cbcfa7371a1f392c4c1e2a3d766be5a704 100644 (file)
@@ -2050,8 +2050,8 @@ sub _contact_pronoun {
     my ($self, $args) = @_;
     my $value = $args->{value};
     my $user = $self->_user;
-    
-    if ($value =~ /^\%group/) {
+
+    if ($value =~ /^\%group\.[^%]+%$/) {
         $self->_contact_exact_group($args);
     }
     elsif ($value =~ /^(%\w+%)$/) {
@@ -2068,11 +2068,17 @@ sub _contact_exact_group {
     my $dbh = Bugzilla->dbh;
     my $user = $self->_user;
     
+    # We already know $value will match this regexp, else we wouldn't be here.
     $value =~ /\%group\.([^%]+)%/;
-    my $group = Bugzilla::Group->check({ name => $1, _error => 'invalid_group_name' });
-    $group->check_members_are_visible();
+    my $group_name = $1;
+    my $group = Bugzilla::Group->check({ name => $group_name, _error => 'invalid_group_name' });
+    # Pass $group_name instead of $group->name to the error message
+    # to not leak the existence of the group.
     $user->in_group($group)
-      || ThrowUserError('invalid_group_name', {name => $group->name});
+      || ThrowUserError('invalid_group_name', { name => $group_name });
+    # Now that we know the user belongs to this group, it's safe
+    # to disclose more information.
+    $group->check_members_are_visible();
 
     my $group_ids = Bugzilla::Group->flatten_group_membership($group->id);
     my $table = "user_group_map_$chart_id";