On Thu Feb 13 09:47:39 2014, mark@stosberg.com wrote:
Show quoted text>
> I believe the handling of inputs with multiple values is documented.
>
> Each one is sent through a constraint individually.
>
> Mark
I couldn't find it in the docs.
I made a patch that keeps the current behavior and allows checking array refs as well.
Thu Feb 13 15:57:18 CET 2014 wesley@schwengle.net
* no_deref
Do not allow array refs to be dereferenced for constraint checking.
diff -rN -u old-dfv/lib/Data/FormValidator/Results.pm new-dfv/lib/Data/FormValidator/Results.pm
--- old-dfv/lib/Data/FormValidator/Results.pm 2014-02-13 16:46:39.461255354 +0100
+++ new-dfv/lib/Data/FormValidator/Results.pm 2014-02-13 16:46:39.465255354 +0100
@@ -367,10 +367,10 @@
$untaint_all = 1;
}
- $self->_check_constraints($private_constraints,\%valid,$untaint_all,\%untaint_hash);
+ $self->_check_constraints($private_constraints,\%valid,$untaint_all,\%untaint_hash, 0, $profile->{no_deref});
my $force_method_p = 1;
- $self->_check_constraints($private_constraint_methods,\%valid,$untaint_all,\%untaint_hash, $force_method_p);
+ $self->_check_constraints($private_constraint_methods,\%valid,$untaint_all,\%untaint_hash, $force_method_p, $profile->{no_deref});
# add back in missing optional fields from the data hash if we need to
for my $field ( keys %data ) {
@@ -1207,7 +1207,8 @@
$valid,
$untaint_all,
$untaint_href,
- $force_method_p) = @_;
+ $force_method_p,
+ $no_deref) = @_;
while ( my ($field,$constraint_list) = each %$constraint_href ) {
next unless exists $valid->{$field};
@@ -1230,7 +1231,7 @@
my $c = $self->_constraint_hash_build($constraint_spec,$untaint_this, $force_method_p);
$c->{is_method} = 1 if $force_method_p;
- my $is_value_list = 1 if (ref $valid->{$field} eq 'ARRAY');
+ my $is_value_list = 1 if (ref $valid->{$field} eq 'ARRAY') && !$no_deref;
my %param_data = ( $self->_get_input_as_hash($self->get_input_data) , %$valid );
if ($is_value_list) {
for (my $i = 0; $i < scalar @{ $valid->{$field}} ; $i++) {
diff -rN -u old-dfv/lib/Data/FormValidator.pm new-dfv/lib/Data/FormValidator.pm
--- old-dfv/lib/Data/FormValidator.pm 2014-02-13 16:46:39.461255354 +0100
+++ new-dfv/lib/Data/FormValidator.pm 2014-02-13 16:46:39.469255354 +0100
@@ -476,6 +476,12 @@
interdependent fields. The keys are arbitrary names that you create and
the values are references to arrays of the field names in each group.
+=head2 no_deref
+
+ no_deref => 1, # or 0
+
+This is a boolean value to allow dereferencing of array refs. Defaults to 0.
+
=head2 allow_unknown
allow_unknown => 0, # or 1
@@ -951,6 +957,7 @@
untaint_regexp_map
debug
allow_unknown
+ no_deref
/);
# If any of the keys in the profile are not listed as