Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
c00ea208
Commit
c00ea208
authored
Aug 22, 2006
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 348542: Move keyword validation out of post_bug.cgi and into Bugzilla::Bug
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=bkor, a=myk
parent
bb496330
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
25 deletions
+20
-25
Bug.pm
Bugzilla/Bug.pm
+16
-0
post_bug.cgi
post_bug.cgi
+4
-25
No files found.
Bugzilla/Bug.pm
View file @
c00ea208
...
...
@@ -35,6 +35,7 @@ use Bugzilla::Constants;
use
Bugzilla::
Field
;
use
Bugzilla::
Flag
;
use
Bugzilla::
FlagType
;
use
Bugzilla::
Keyword
;
use
Bugzilla::
User
;
use
Bugzilla::
Util
;
use
Bugzilla::
Error
;
...
...
@@ -333,6 +334,21 @@ sub _check_component {
return
$obj
;
}
sub
_check_keywords
{
my
(
$keyword_string
)
=
@_
;
$keyword_string
=
trim
(
$keyword_string
);
return
[]
if
(
!
$keyword_string
||
!
Bugzilla
->
user
->
in_group
(
'editbugs'
));
my
%
keyword_ids
;
foreach
my
$keyword
(
split
(
/[\s,]+/
,
$keyword_string
))
{
next
unless
$keyword
;
my
$obj
=
new
Bugzilla::
Keyword
({
name
=>
$keyword
});
ThrowUserError
(
"unknown_keyword"
,
{
keyword
=>
$keyword
})
if
!
$obj
;
$keyword_ids
{
$obj
->
id
}
=
1
;
}
return
[
keys
%
keyword_ids
];
}
sub
_check_product
{
my
(
$name
)
=
@_
;
# Check that the product exists and that the user
...
...
post_bug.cgi
View file @
c00ea208
...
...
@@ -221,28 +221,7 @@ $cgi->param(-name => 'component_id', -value => $component->id);
push
(
@used_fields
,
"component_id"
);
my
@cc_ids
=
@
{
Bugzilla::Bug::
_check_cc
([
$cgi
->
param
(
'cc'
)])};
# Check for valid keywords and create list of keywords to be added to db
# (validity routine copied from process_bug.cgi)
my
@keywordlist
;
my
%
keywordseen
;
if
(
$cgi
->
param
(
'keywords'
)
&&
UserInGroup
(
"editbugs"
))
{
foreach
my
$keyword
(
split
(
/[\s,]+/
,
$cgi
->
param
(
'keywords'
)))
{
if
(
$keyword
eq
''
)
{
next
;
}
my
$keyword_obj
=
new
Bugzilla::
Keyword
({
name
=>
$keyword
});
if
(
!
$keyword_obj
)
{
ThrowUserError
(
"unknown_keyword"
,
{
keyword
=>
$keyword
});
}
if
(
!
$keywordseen
{
$keyword_obj
->
id
})
{
push
(
@keywordlist
,
$keyword_obj
->
id
);
$keywordseen
{
$keyword_obj
->
id
}
=
1
;
}
}
}
my
@keyword_ids
=
@
{
Bugzilla::Bug::
_check_keywords
(
$cgi
->
param
(
'keywords'
))};
if
(
Bugzilla
->
params
->
{
"strict_isolation"
})
{
my
@blocked_users
=
();
...
...
@@ -439,12 +418,12 @@ my @all_deps;
my
$sth_addkeyword
=
$dbh
->
prepare
(
q{
INSERT INTO keywords (bug_id, keywordid) VALUES (?, ?)}
);
if
(
UserInGroup
(
"editbugs"
))
{
foreach
my
$keyword
(
@keyword
list
)
{
foreach
my
$keyword
(
@keyword
_ids
)
{
$sth_addkeyword
->
execute
(
$id
,
$keyword
);
}
if
(
@keyword
list
)
{
if
(
@keyword
_ids
)
{
# Make sure that we have the correct case for the kw
my
$kw_ids
=
join
(
', '
,
@keyword
list
);
my
$kw_ids
=
join
(
', '
,
@keyword
_ids
);
my
$list
=
$dbh
->
selectcol_arrayref
(
qq{
SELECT name
FROM keyworddefs
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment