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
0f832a59
Commit
0f832a59
authored
Jul 20, 2005
by
lpsolit%gmail.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 285112: Move ValidateBugID out of CGI.pl - Patch by Frédéric Buclin…
Bug 285112: Move ValidateBugID out of CGI.pl - Patch by Frédéric Buclin <LpSolit@gmail.com> r=joel,wicked a=justdave
parent
5f9f484f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
46 deletions
+47
-46
Bug.pm
Bugzilla/Bug.pm
+45
-1
CGI.pl
CGI.pl
+0
-45
showdependencygraph.cgi
showdependencygraph.cgi
+1
-0
showdependencytree.cgi
showdependencytree.cgi
+1
-0
No files found.
Bugzilla/Bug.pm
View file @
0f832a59
...
@@ -50,7 +50,7 @@ use Bugzilla::Error;
...
@@ -50,7 +50,7 @@ use Bugzilla::Error;
use
base
qw(Exporter)
;
use
base
qw(Exporter)
;
@
Bugzilla::Bug::
EXPORT
=
qw(
@
Bugzilla::Bug::
EXPORT
=
qw(
AppendComment ValidateComment
AppendComment ValidateComment
bug_alias_to_id ValidateBugAlias
bug_alias_to_id ValidateBugAlias
ValidateBugID
RemoveVotes CheckIfVotedConfirmed
RemoveVotes CheckIfVotedConfirmed
)
;
)
;
...
@@ -1102,6 +1102,50 @@ sub CheckIfVotedConfirmed {
...
@@ -1102,6 +1102,50 @@ sub CheckIfVotedConfirmed {
# Field Validation
# Field Validation
#
#
# Validates and verifies a bug ID, making sure the number is a
# positive integer, that it represents an existing bug in the
# database, and that the user is authorized to access that bug.
# We detaint the number here, too.
sub
ValidateBugID
{
my
(
$id
,
$field
)
=
@_
;
my
$dbh
=
Bugzilla
->
dbh
;
my
$user
=
Bugzilla
->
user
;
# Get rid of white-space around the ID.
$id
=
trim
(
$id
);
# If the ID isn't a number, it might be an alias, so try to convert it.
my
$alias
=
$id
;
if
(
!
detaint_natural
(
$id
))
{
$id
=
bug_alias_to_id
(
$alias
);
$id
||
ThrowUserError
(
"invalid_bug_id_or_alias"
,
{
'bug_id'
=>
$alias
,
'field'
=>
$field
});
}
# Modify the calling code's original variable to contain the trimmed,
# converted-from-alias ID.
$_
[
0
]
=
$id
;
# First check that the bug exists
$dbh
->
selectrow_array
(
"SELECT bug_id FROM bugs WHERE bug_id = ?"
,
undef
,
$id
)
||
ThrowUserError
(
"invalid_bug_id_non_existent"
,
{
'bug_id'
=>
$id
});
return
if
(
defined
$field
&&
(
$field
eq
"dependson"
||
$field
eq
"blocked"
));
return
if
$user
->
can_see_bug
(
$id
);
# The user did not pass any of the authorization tests, which means they
# are not authorized to see the bug. Display an error and stop execution.
# The error the user sees depends on whether or not they are logged in
# (i.e. $user->id contains the user's positive integer ID).
if
(
$user
->
id
)
{
ThrowUserError
(
"bug_access_denied"
,
{
'bug_id'
=>
$id
});
}
else
{
ThrowUserError
(
"bug_access_query"
,
{
'bug_id'
=>
$id
});
}
}
# ValidateBugAlias:
# ValidateBugAlias:
# Check that the bug alias is valid and not used by another bug. If
# Check that the bug alias is valid and not used by another bug. If
# curr_id is specified, verify the alias is not used for any other
# curr_id is specified, verify the alias is not used for any other
...
...
CGI.pl
View file @
0f832a59
...
@@ -107,51 +107,6 @@ sub CheckFormFieldDefined ($$) {
...
@@ -107,51 +107,6 @@ sub CheckFormFieldDefined ($$) {
}
}
}
}
sub
ValidateBugID
{
# Validates and verifies a bug ID, making sure the number is a
# positive integer, that it represents an existing bug in the
# database, and that the user is authorized to access that bug.
# We detaint the number here, too
my
(
$id
,
$field
)
=
@_
;
# Get rid of white-space around the ID.
$id
=
trim
(
$id
);
# If the ID isn't a number, it might be an alias, so try to convert it.
my
$alias
=
$id
;
if
(
!
detaint_natural
(
$id
))
{
$id
=
bug_alias_to_id
(
$alias
);
$id
||
ThrowUserError
(
"invalid_bug_id_or_alias"
,
{
'bug_id'
=>
$alias
,
'field'
=>
$field
});
}
# Modify the calling code's original variable to contain the trimmed,
# converted-from-alias ID.
$_
[
0
]
=
$id
;
# First check that the bug exists
SendSQL
(
"SELECT bug_id FROM bugs WHERE bug_id = $id"
);
FetchOneColumn
()
||
ThrowUserError
(
"invalid_bug_id_non_existent"
,
{
'bug_id'
=>
$id
});
return
if
(
defined
$field
&&
(
$field
eq
"dependson"
||
$field
eq
"blocked"
));
return
if
Bugzilla
->
user
->
can_see_bug
(
$id
);
# The user did not pass any of the authorization tests, which means they
# are not authorized to see the bug. Display an error and stop execution.
# The error the user sees depends on whether or not they are logged in
# (i.e. $::userid contains the user's positive integer ID).
if
(
$::userid
)
{
ThrowUserError
(
"bug_access_denied"
,
{
'bug_id'
=>
$id
});
}
else
{
ThrowUserError
(
"bug_access_query"
,
{
'bug_id'
=>
$id
});
}
}
sub
CheckEmailSyntax
{
sub
CheckEmailSyntax
{
my
(
$addr
)
=
(
@_
);
my
(
$addr
)
=
(
@_
);
my
$match
=
Param
(
'emailregexp'
);
my
$match
=
Param
(
'emailregexp'
);
...
...
showdependencygraph.cgi
View file @
0f832a59
...
@@ -30,6 +30,7 @@ use Bugzilla;
...
@@ -30,6 +30,7 @@ use Bugzilla;
use
Bugzilla::
Config
qw(:DEFAULT $webdotdir)
;
use
Bugzilla::
Config
qw(:DEFAULT $webdotdir)
;
use
Bugzilla::
Util
;
use
Bugzilla::
Util
;
use
Bugzilla::
BugMail
;
use
Bugzilla::
BugMail
;
use
Bugzilla::
Bug
;
require
"CGI.pl"
;
require
"CGI.pl"
;
...
...
showdependencytree.cgi
View file @
0f832a59
...
@@ -28,6 +28,7 @@ use strict;
...
@@ -28,6 +28,7 @@ use strict;
use
lib
qw(.)
;
use
lib
qw(.)
;
require
"CGI.pl"
;
require
"CGI.pl"
;
use
Bugzilla::
User
;
use
Bugzilla::
User
;
use
Bugzilla::
Bug
;
# Use global template variables.
# Use global template variables.
use
vars
qw($template $vars)
;
use
vars
qw($template $vars)
;
...
...
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