tpac : sanity check record ID in detail page path
authorBill Erickson <berick@esilibrary.com>
Tue, 29 May 2012 13:39:58 +0000 (09:39 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 30 Jul 2012 19:05:04 +0000 (15:05 -0400)
If the ID is malformed (or nonexistent), return a BAD_REQUEST status and
exit early to avoid any unnecessary DB lookups and error logging.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm

index bd5a22e..70010bd 100644 (file)
@@ -21,8 +21,10 @@ sub load_record {
 
     $self->timelog("load_record() began");
 
-    my $rec_id = $ctx->{page_args}->[0]
-        or return Apache2::Const::HTTP_BAD_REQUEST;
+    my $rec_id = $ctx->{page_args}->[0];
+
+    return Apache2::Const::HTTP_BAD_REQUEST 
+        unless $rec_id and $rec_id =~ /^\d+$/;
 
     $self->added_content_stage1($rec_id);
     $self->timelog("past added content stage 1");