From c7bb724eb31f848e3d6f78fdcee5ee70ab0516ac Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Mon, 12 Dec 2005 10:38:40 +0000 Subject: Bug 319089: editkeywords.cgi throws an error when action="edit" or "delete" and the "id" parameter is invalid - Patch by Frédéric Buclin r=wicked a=justdave MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- editkeywords.cgi | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'editkeywords.cgi') diff --git a/editkeywords.cgi b/editkeywords.cgi index da412bfdc..5397f0aa5 100755 --- a/editkeywords.cgi +++ b/editkeywords.cgi @@ -53,6 +53,14 @@ sub Validate { $_[1] = $description; } +sub ValidateKeyID { + my $id = shift; + + $id = trim($id || 0); + detaint_natural($id) || ThrowCodeError('invalid_keyword_id'); + return $id; +} + # # Preliminary checks: @@ -165,8 +173,7 @@ if ($action eq 'new') { # if ($action eq 'edit') { - my $id = trim($cgi->param('id')); - detaint_natural($id); + my $id = ValidateKeyID(scalar $cgi->param('id')); # get data of keyword my ($name, $description) = @@ -201,8 +208,7 @@ if ($action eq 'edit') { # if ($action eq 'update') { - my $id = $cgi->param('id'); - detaint_natural($id); + my $id = ValidateKeyID(scalar $cgi->param('id')); my $name = trim($cgi->param('name') || ''); my $description = trim($cgi->param('description') || ''); @@ -234,8 +240,7 @@ if ($action eq 'update') { if ($action eq 'delete') { - my $id = $cgi->param('id'); - detaint_natural($id); + my $id = ValidateKeyID(scalar $cgi->param('id')); my $name = $dbh->selectrow_array('SELECT name FROM keyworddefs WHERE id= ?', undef, $id); -- cgit v1.2.3-24-g4f1b