Commit 6bd37cce authored by bugreport%peshkin.net's avatar bugreport%peshkin.net

Bug 184256 Canedit group_control_map entry does not prevent making attachments

r=bbaetz a=justdave
parent c457b4c4
...@@ -65,6 +65,11 @@ sub query ...@@ -65,6 +65,11 @@ sub query
my ($bugid) = @_; my ($bugid) = @_;
my $in_editbugs = &::UserInGroup("editbugs"); my $in_editbugs = &::UserInGroup("editbugs");
&::SendSQL("SELECT product_id
FROM bugs
WHERE bug_id = $bugid");
my $productid = &::FetchOneColumn();
my $caneditproduct = &::CanEditProductId($productid);
# Retrieve a list of attachments for this bug and write them into an array # Retrieve a list of attachments for this bug and write them into an array
# of hashes in which each hash represents a single attachment. # of hashes in which each hash represents a single attachment.
...@@ -88,8 +93,8 @@ sub query ...@@ -88,8 +93,8 @@ sub query
# ie the are the submitter, or they have canedit. # ie the are the submitter, or they have canedit.
# Also show the link if the user is not logged in - in that cae, # Also show the link if the user is not logged in - in that cae,
# They'll be prompted later # They'll be prompted later
$a{'canedit'} = ($::userid == 0 || $submitter_id == $::userid || $a{'canedit'} = ($::userid == 0 || (($submitter_id == $::userid ||
$in_editbugs); $in_editbugs) && $caneditproduct));
push @attachments, \%a; push @attachments, \%a;
} }
......
...@@ -65,6 +65,11 @@ sub query ...@@ -65,6 +65,11 @@ sub query
my ($bugid) = @_; my ($bugid) = @_;
my $in_editbugs = &::UserInGroup("editbugs"); my $in_editbugs = &::UserInGroup("editbugs");
&::SendSQL("SELECT product_id
FROM bugs
WHERE bug_id = $bugid");
my $productid = &::FetchOneColumn();
my $caneditproduct = &::CanEditProductId($productid);
# Retrieve a list of attachments for this bug and write them into an array # Retrieve a list of attachments for this bug and write them into an array
# of hashes in which each hash represents a single attachment. # of hashes in which each hash represents a single attachment.
...@@ -88,8 +93,8 @@ sub query ...@@ -88,8 +93,8 @@ sub query
# ie the are the submitter, or they have canedit. # ie the are the submitter, or they have canedit.
# Also show the link if the user is not logged in - in that cae, # Also show the link if the user is not logged in - in that cae,
# They'll be prompted later # They'll be prompted later
$a{'canedit'} = ($::userid == 0 || $submitter_id == $::userid || $a{'canedit'} = ($::userid == 0 || (($submitter_id == $::userid ||
$in_editbugs); $in_editbugs) && $caneditproduct));
push @attachments, \%a; push @attachments, \%a;
} }
......
...@@ -77,12 +77,14 @@ elsif ($action eq "enter") ...@@ -77,12 +77,14 @@ elsif ($action eq "enter")
{ {
confirm_login(); confirm_login();
ValidateBugID($::FORM{'bugid'}); ValidateBugID($::FORM{'bugid'});
validateCanChangeBug($::FORM{'bugid'});
enter(); enter();
} }
elsif ($action eq "insert") elsif ($action eq "insert")
{ {
confirm_login(); confirm_login();
ValidateBugID($::FORM{'bugid'}); ValidateBugID($::FORM{'bugid'});
validateCanChangeBug($::FORM{'bugid'});
ValidateComment($::FORM{'comment'}); ValidateComment($::FORM{'comment'});
validateFilename(); validateFilename();
validateIsPatch(); validateIsPatch();
...@@ -105,6 +107,7 @@ elsif ($action eq "update") ...@@ -105,6 +107,7 @@ elsif ($action eq "update")
ValidateComment($::FORM{'comment'}); ValidateComment($::FORM{'comment'});
validateID(); validateID();
validateCanEdit($::FORM{'id'}); validateCanEdit($::FORM{'id'});
validateCanChangeAttachment($::FORM{'id'});
validateDescription(); validateDescription();
validateIsPatch(); validateIsPatch();
validateContentType() unless $::FORM{'ispatch'}; validateContentType() unless $::FORM{'ispatch'};
...@@ -171,6 +174,29 @@ sub validateCanEdit ...@@ -171,6 +174,29 @@ sub validateCanEdit
|| ThrowUserError("illegal_attachment_edit"); || ThrowUserError("illegal_attachment_edit");
} }
sub validateCanChangeAttachment
{
my ($attachid) = @_;
SendSQL("SELECT product_id
FROM attachments, bugs
WHERE attach_id = $attachid
AND bugs.bug_id = attachments.bug_id");
my $productid = FetchOneColumn();
CanEditProductId($productid)
|| ThrowUserError("illegal_attachment_edit");
}
sub validateCanChangeBug
{
my ($bugid) = @_;
SendSQL("SELECT product_id
FROM bugs
WHERE bug_id = $bugid");
my $productid = FetchOneColumn();
CanEditProductId($productid)
|| ThrowUserError("illegal_attachment_edit");
}
sub validateDescription sub validateDescription
{ {
$::FORM{'description'} $::FORM{'description'}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment