improved error diagnostic for FromCGI->untaint_columns

[prev] [thread] [next] [Date index for 2004/10/29]

From: Dave Howorth
Subject: improved error diagnostic for FromCGI->untaint_columns
Date: 12:23 on 29 Oct 2004
Somehow, my source got corrupted so one argument to untaint_columns was 
deleted. This produced a fairly obscure error message from 
FromCGI->untaint_handlers which is called from the depths of the 
framework I'm using:

   Can't use string ("printable") as an ARRAY ref while "strict refs"
   in use at /usr/local/share/perl/5.6.1/Class/DBI/FromCGI.pm line 266.

This is obviously not FromCGI's fault but it would have been much easier 
to diagnose my problem if I'd got an error when I passed obviously junk 
arguments to untaint_columns, because at least I wrote that call! Can I 
therefore suggest the following patch:

--- CDBI-FromCGI.pm	Fri Oct 29 13:03:35 2004
+++ Class/DBI/FromCGI.pm	Fri Oct 29 13:10:45 2004
@@ -156,6 +156,7 @@ use base 'Exporter';
               cgi_update_errors untaint_type/;

  sub untaint_columns {
+  die "bad args to untaint_columns" unless @_ % 2;
    my ($class, %args) = @_;
    $class->mk_classdata('__untaint_types')
      unless $class->can('__untaint_types');


Cheers, Dave

improved error diagnostic for FromCGI->untaint_columns
Dave Howorth 12:23 on 29 Oct 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52