Subject: | improved error diagnostic for FromCGI->untaint_columns |
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!
FromCGI->untaint_columns does not produce the "Odd number of elements in hash assignment" message that I would expect, even with -W on the command line. I don't know how to fix that, so instead I 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