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
e51425da
Commit
e51425da
authored
May 04, 2005
by
lpsolit%gmail.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 248386: Add support for Alias to post_bug.cgi - Patch by Albert Ting…
Bug 248386: Add support for Alias to post_bug.cgi - Patch by Albert Ting <altlst@sonic.net> r=LpSolit a=justdave
parent
3f138672
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
36 deletions
+71
-36
Bug.pm
Bugzilla/Bug.pm
+53
-1
post_bug.cgi
post_bug.cgi
+9
-0
process_bug.cgi
process_bug.cgi
+4
-34
user-error.html.tmpl
template/en/default/global/user-error.html.tmpl
+5
-1
No files found.
Bugzilla/Bug.pm
View file @
e51425da
...
...
@@ -50,7 +50,7 @@ use Bugzilla::Error;
use
base
qw(Exporter)
;
@
Bugzilla::Bug::
EXPORT
=
qw(
AppendComment ValidateComment
bug_alias_to_id
bug_alias_to_id
ValidateBugAlias
RemoveVotes CheckIfVotedConfirmed
)
;
...
...
@@ -982,6 +982,58 @@ sub CheckIfVotedConfirmed {
return
$ret
;
}
#
# Field Validation
#
# ValidateBugAlias:
# 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
# bug id.
sub
ValidateBugAlias
{
my
(
$alias
,
$curr_id
)
=
@_
;
my
$dbh
=
Bugzilla
->
dbh
;
$alias
=
trim
(
$alias
||
""
);
trick_taint
(
$alias
);
if
(
$alias
eq
""
)
{
ThrowUserError
(
"alias_not_defined"
);
}
# Make sure the alias isn't too long.
if
(
length
(
$alias
)
>
20
)
{
ThrowUserError
(
"alias_too_long"
);
}
# Make sure the alias is unique.
my
$query
=
"SELECT bug_id FROM bugs WHERE alias = ?"
;
if
(
detaint_natural
(
$curr_id
))
{
$query
.=
" AND bug_id != $curr_id"
;
}
my
$id
=
$dbh
->
selectrow_array
(
$query
,
undef
,
$alias
);
my
$vars
=
{};
$vars
->
{
'alias'
}
=
$alias
;
if
(
$id
)
{
$vars
->
{
'bug_link'
}
=
&::
GetBugLink
(
$id
,
$id
);
ThrowUserError
(
"alias_in_use"
,
$vars
);
}
# Make sure the alias isn't just a number.
if
(
$alias
=~
/^\d+$/
)
{
ThrowUserError
(
"alias_is_numeric"
,
$vars
);
}
# Make sure the alias has no commas or spaces.
if
(
$alias
=~
/[, ]/
)
{
ThrowUserError
(
"alias_has_comma_or_space"
,
$vars
);
}
$_
[
0
]
=
$alias
;
}
sub
AUTOLOAD
{
use
vars
qw($AUTOLOAD)
;
my
$attr
=
$AUTOLOAD
;
...
...
post_bug.cgi
View file @
e51425da
...
...
@@ -144,6 +144,15 @@ my @bug_fields = ("version", "rep_platform",
"bug_status"
,
"bug_file_loc"
,
"short_desc"
,
"target_milestone"
,
"status_whiteboard"
);
if
(
Param
(
"usebugaliases"
))
{
my
$alias
=
trim
(
$cgi
->
param
(
'alias'
)
||
""
);
if
(
$alias
ne
""
)
{
ValidateBugAlias
(
$alias
);
$cgi
->
param
(
'alias'
,
$alias
);
push
(
@bug_fields
,
"alias"
);
}
}
# Retrieve the default QA contact if the field is empty
if
(
Param
(
"useqacontact"
))
{
my
$qa_contact
;
...
...
process_bug.cgi
View file @
e51425da
...
...
@@ -768,47 +768,17 @@ if (Param("usebugaliases") && defined $cgi->param('alias')) {
# for one bug at a time, so ignore the alias change unless only a single
# bug is being changed.
if
(
scalar
(
@idlist
)
==
1
)
{
# Validate the alias if the user entered one.
if
(
$alias
ne
""
)
{
# Make sure the alias isn't too long.
if
(
length
(
$alias
)
>
20
)
{
ThrowUserError
(
"alias_too_long"
);
}
# Make sure the alias is unique.
my
$escaped_alias
=
SqlQuote
(
$alias
);
my
$vars
=
{
alias
=>
$alias
};
SendSQL
(
"SELECT bug_id FROM bugs WHERE alias = $escaped_alias "
.
"AND bug_id != $idlist[0]"
);
my
$id
=
FetchOneColumn
();
if
(
$id
)
{
$vars
->
{
'bug_link'
}
=
GetBugLink
(
$id
,
"Bug $id"
);
ThrowUserError
(
"alias_in_use"
,
$vars
);
}
# Make sure the alias isn't just a number.
if
(
$alias
=~
/^\d+$/
)
{
ThrowUserError
(
"alias_is_numeric"
,
$vars
);
}
# Make sure the alias has no commas or spaces.
if
(
$alias
=~
/[, ]/
)
{
ThrowUserError
(
"alias_has_comma_or_space"
,
$vars
);
}
}
# Add the alias change to the query. If the field contains the blank
# value, make the field be NULL to indicate that the bug has no alias.
# Otherwise, if the field contains a value, update the record
# with that value.
DoComma
();
$::query
.=
"alias = "
;
if
(
$alias
eq
""
)
{
$::query
.=
"NULL"
;
if
(
$alias
ne
""
)
{
ValidateBugAlias
(
$alias
,
$idlist
[
0
]);
$::query
.=
$dbh
->
quote
(
$alias
);
}
else
{
$::query
.=
SqlQuote
(
$alias
)
;
$::query
.=
"NULL"
;
}
}
}
...
...
template/en/default/global/user-error.html.tmpl
View file @
e51425da
...
...
@@ -76,9 +76,13 @@
[% ELSIF error == "alias_in_use" %]
[% title = "Alias In Use" %]
[% bug_link FILTER none %] has already taken the alias
[%
terms.Bug %] [%+
bug_link FILTER none %] has already taken the alias
<em>[% alias FILTER html %]</em>. Please choose another one.
[% ELSIF error == "alias_not_defined" %]
[% title = "Alias Is Not Defined" %]
You did not supply an alias to this [% terms.bug %].
[% ELSIF error == "alias_is_numeric" %]
[% title = "Alias Is Numeric" %]
You tried to give this [% terms.bug %] the alias <em>[% alias FILTER html %]</em>,
...
...
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