aboutsummaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2005-05-04 01:44:53 +0000
committerlpsolit%gmail.com <>2005-05-04 01:44:53 +0000
commite51425da1f1fe8ee831bfb8d4c091d9e08ae4dce (patch)
treef00cb30677e4c5759ca91186bf9bfd113baa88af /Bugzilla
parent3f138672bdd7fd4aba0b5c78b3541138174bd9f0 (diff)
downloadbugs-e51425da1f1fe8ee831bfb8d4c091d9e08ae4dce.tar
bugs-e51425da1f1fe8ee831bfb8d4c091d9e08ae4dce.tar.gz
bugs-e51425da1f1fe8ee831bfb8d4c091d9e08ae4dce.tar.bz2
bugs-e51425da1f1fe8ee831bfb8d4c091d9e08ae4dce.tar.xz
bugs-e51425da1f1fe8ee831bfb8d4c091d9e08ae4dce.zip
Bug 248386: Add support for Alias to post_bug.cgi - Patch by Albert Ting <altlst@sonic.net> r=LpSolit a=justdave
Diffstat (limited to 'Bugzilla')
-rwxr-xr-xBugzilla/Bug.pm54
1 files changed, 53 insertions, 1 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 7d93139a1..4439a7993 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -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;