r3271 - in /packages/libdata-formvalidator-perl/branches/upstream/current: ./ lib/Data/ lib/Data/FormValidator/ lib/Data/FormValidator/Constraints/ t/

gregoa-guest at users.alioth.debian.org gregoa-guest at users.alioth.debian.org
Fri Jul 14 19:57:49 UTC 2006


Author: gregoa-guest
Date: Fri Jul 14 19:57:48 2006
New Revision: 3271

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=3271
Log:
Load /tmp/tmp.TIQvA25430/libdata-formvalidator-perl-4.30 into
packages/libdata-formvalidator-perl/branches/upstream/current.

Added:
    packages/libdata-formvalidator-perl/branches/upstream/current/t/FV_length.t
Modified:
    packages/libdata-formvalidator-perl/branches/upstream/current/Changes
    packages/libdata-formvalidator-perl/branches/upstream/current/MANIFEST
    packages/libdata-formvalidator-perl/branches/upstream/current/META.yml
    packages/libdata-formvalidator-perl/branches/upstream/current/RELEASE_NOTES
    packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator.pm
    packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator/Constraints.pm
    packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator/Constraints/Upload.pm
    packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator/Results.pm
    packages/libdata-formvalidator-perl/branches/upstream/current/t/regexp_common_closure.t
    packages/libdata-formvalidator-perl/branches/upstream/current/t/untaint.pl

Modified: packages/libdata-formvalidator-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/branches/upstream/current/Changes?rev=3271&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/branches/upstream/current/Changes (original)
+++ packages/libdata-formvalidator-perl/branches/upstream/current/Changes Fri Jul 14 19:57:48 2006
@@ -1,3 +1,28 @@
+4.30 Mon Jul 10 21:41:37 EDT 2006
+    [ENHANCEMENTS]
+    - A new method for constraint writers has been added: untainted_constraint_value().    
+      If you have written a constraint which untaints, use this method to return the
+      untainted result. It will prepare the right result whether the user has requested
+      untainting or not. (Mark Stosberg)
+
+    - New built-in constraints added:
+
+        FV_min_length(3),
+        FV_max_length(100),
+        FV_length_between(3,100),
+
+        These constraints can optionally perform untainting. (Mark Stosberg)
+
+    - We now work around a bug in File::MMagic which could cause some filehandles
+      to be corrupted after after the file_format constraint was used.  
+
+    [BUG FIXES]
+    - Regexp::Common regular expressions which accepted zero as a valid input would
+      have wrongly failed their constraints unless untainting was enabled. (Mark Stosberg)
+
+    [INTERNALS]
+    - Improved documentation for built-in constraints. (Mark Stosberg)
+
 4.20 Mon Jun 12 20:44:36 EDT 2006
     [ENHANCEMENTS]
     - Documentation in Data::FormValidator::Filters has been improved. (Mark Stosberg}

Modified: packages/libdata-formvalidator-perl/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/branches/upstream/current/MANIFEST?rev=3271&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/branches/upstream/current/MANIFEST (original)
+++ packages/libdata-formvalidator-perl/branches/upstream/current/MANIFEST Fri Jul 14 19:57:48 2006
@@ -34,6 +34,7 @@
 t/27_qualify_ref_happy_death.t
 t/28_defaults_for_new.t
 t/30_filter_definedness.t
+t/FV_length.t
 t/ValidatorPackagesTest1.pm
 t/ValidatorPackagesTest2.pm
 t/any_errors.t

Modified: packages/libdata-formvalidator-perl/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/branches/upstream/current/META.yml?rev=3271&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/branches/upstream/current/META.yml (original)
+++ packages/libdata-formvalidator-perl/branches/upstream/current/META.yml Fri Jul 14 19:57:48 2006
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name: Data-FormValidator
-version: 4.20
+version: 4.30
 author:
   - Mark Stosberg <mark at summersault.com>
 abstract: |-
@@ -18,19 +18,19 @@
 provides:
   Data::FormValidator:
     file: lib/Data/FormValidator.pm
-    version: 4.20
+    version: 4.30
   Data::FormValidator::Constraints:
     file: lib/Data/FormValidator/Constraints.pm
-    version: 4.14
+    version: 4.3
   Data::FormValidator::Constraints::Dates:
     file: lib/Data/FormValidator/Constraints/Dates.pm
     version: 1.01
   Data::FormValidator::Constraints::RegexpCommon:
     file: lib/Data/FormValidator/Results.pm
-    version: 4.14
+    version: 4.3
   Data::FormValidator::Constraints::Upload:
     file: lib/Data/FormValidator/Constraints/Upload.pm
-    version: 1.1
+    version: 1.2
   Data::FormValidator::ConstraintsFactory:
     file: lib/Data/FormValidator/ConstraintsFactory.pm
     version: 1.4
@@ -39,5 +39,5 @@
     version: 4.1
   Data::FormValidator::Results:
     file: lib/Data/FormValidator/Results.pm
-    version: 4.14
+    version: 4.3
 generated_by: Module::Build version 0.2611

Modified: packages/libdata-formvalidator-perl/branches/upstream/current/RELEASE_NOTES
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/branches/upstream/current/RELEASE_NOTES?rev=3271&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/branches/upstream/current/RELEASE_NOTES (original)
+++ packages/libdata-formvalidator-perl/branches/upstream/current/RELEASE_NOTES Fri Jul 14 19:57:48 2006
@@ -19,7 +19,7 @@
 
   constraint_methods allows normal looking parameter passing:
 
-  my_field => length_is_between(10,20);
+  my_field => FV_length_between(10,20);
 
 * Using a 'constraint_method' as a hash was awkward, because you had  
   to use a hashref to pass it in:

Modified: packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator.pm?rev=3271&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator.pm (original)
+++ packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator.pm Fri Jul 14 19:57:48 2006
@@ -31,7 +31,7 @@
 
 use vars qw( $VERSION $AUTOLOAD @ISA @EXPORT_OK %EXPORT_TAGS );
 
-$VERSION = '4.20';
+$VERSION = '4.30';
 
 require Exporter;
 @ISA = qw(Exporter);

Modified: packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator/Constraints.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator/Constraints.pm?rev=3271&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator/Constraints.pm (original)
+++ packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator/Constraints.pm Fri Jul 14 19:57:48 2006
@@ -23,7 +23,7 @@
 use strict;
 use vars qw/$AUTOLOAD @ISA @EXPORT_OK %EXPORT_TAGS $VERSION/;
 
-$VERSION = 4.14;
+$VERSION = 4.30;
 
 require Exporter;
 @ISA = qw(Exporter);
@@ -77,6 +77,9 @@
     @EXPORT_OK = (
         @closures,
         qw(
+        FV_length_between
+        FV_min_length
+        FV_max_length
         valid_american_phone
         valid_cc_exp
         valid_cc_number
@@ -162,7 +165,8 @@
 
                         no strict "refs";
                         my $re = &$sub(-keep=>1, at params);
-                        return ($dfv->get_current_constraint_value =~ qr/^$re$/) ? $1 : undef; 
+                        my ($match) = ($dfv->get_current_constraint_value =~ qr/^($re)$/);
+                        return $dfv->untainted_constraint_value($match);
                     }
                 }
             }
@@ -224,11 +228,76 @@
     }
 }
 
-=pod
-
-=over 
-
-=item email
+=head2 FV_length_between(1,23) 
+
+=head2 FV_max_length(23)
+
+=head2 FV_min_length(1)
+
+  use Data::FormValidator::Constraints qw(
+    FV_length_between
+    FV_min_length
+    FV_max_length
+  );
+
+  constraint_methods => {
+
+    # specify a min and max, inclusive
+    last_name        => FV_length_between(1,23),
+
+  }
+
+Specify a length constraint for a field. 
+
+These constraints have a different naming convention because they are higher-order
+functions. They take input and return a code reference to a standard constraint
+method. A constraint name of C<length_between>, C<min_length>, or C<max_length> will be set,
+corresponding to the function name you choose. 
+
+The checks are all inclusive, so a max length of '100' will allow the length 100. 
+
+This constraint I<will> untaint your data if you have untainting turned on. However,
+a length check alone may not be enough to insure the safety of the data you are receiving.
+Using additional constraints to check the data is encouraged. 
+
+=cut
+
+sub FV_length_between {
+    my ($min,$max) = @_;
+    if (not (defined $min and defined $max)) {
+            croak "min and max are required";
+    }
+    return sub {
+        my ($dfv,$value) = @_;
+        $dfv->name_this('length_between');
+        my ($match) = ($value =~ m/^(.{$min,$max})$/);
+        return $dfv->untainted_constraint_value($match);
+    }
+}
+
+sub FV_max_length {
+    my ($max) = @_;
+    croak "max is required" unless defined $max;
+    return sub {
+        my ($dfv,$value) = @_;
+        $dfv->name_this('max_length');
+        my ($match) = ($value =~ m/^(.{0,$max}$)/);
+        return $dfv->untainted_constraint_value($match);
+    }
+}
+
+sub FV_min_length {
+    my ($min) = @_;
+    croak "min is required" unless defined $min;
+    return sub {
+        my ($dfv,$value) = @_;
+        $dfv->name_this('min_length');
+        my ($match) = ($value =~ m/^(.{$min,})$/);
+        return $dfv->untainted_constraint_value($match);
+    }
+}
+
+=head2 email
 
 Checks if the email LOOKS LIKE an email address. This should be sufficient
 99% of the time. 
@@ -263,9 +332,7 @@
 AB BC MB NB NF NL NS NT NU ON PE QC SK YT YK
 EOF
 
-=pod
-
-=item state_or_province
+=head2 state_or_province
 
 This one checks if the input correspond to an american state or a canadian
 province.
@@ -282,12 +349,10 @@
 	}
 }
 
-=pod
-
-=item state
+=head2 state
 
 This one checks if the input is a valid two letter abbreviation of an 
-american state.
+American state.
 
 =cut
 
@@ -299,11 +364,9 @@
     else { return undef; }
 }
 
-=pod
-
-=item province
-
-This checks if the input is a two letter canadian province
+=head2 province
+
+This checks if the input is a two letter Canadian province
 abbreviation.
 
 =cut
@@ -316,12 +379,10 @@
     else { return undef; }
 }
 
-=pod
-
-=item zip_or_postcode
-
-This constraints checks if the input is an american zipcode or a
-canadian postal code.
+=head2 zip_or_postcode
+
+This constraints checks if the input is an American zipcode or a
+Canadian postal code.
 
 =cut
 
@@ -336,7 +397,7 @@
 }
 =pod
 
-=item postcode
+=head2 postcode
 
 This constraints checks if the input is a valid Canadian postal code.
 
@@ -351,9 +412,7 @@
     else { return undef; }
 }
 
-=pod
-
-=item zip
+=head2 zip
 
 This input validator checks if the input is a valid american zipcode :
 5 digits followed by an optional mailbox number.
@@ -368,9 +427,7 @@
     else { return undef; }
 }
 
-=pod
-
-=item phone
+=head2 phone
 
 This one checks if the input looks like a phone number, (if it
 contains at least 6 digits.)
@@ -386,9 +443,7 @@
     else { return undef; }
 }
 
-=pod
-
-=item american_phone
+=head2 american_phone
 
 This constraints checks if the number is a possible North American style
 of phone number : (XXX) XXX-XXXX. It has to contains 7 or more digits.
@@ -405,9 +460,7 @@
 }
 
 
-=pod
-
-=item cc_number
+=head2 cc_number
 
 This constraint references the value of a credit card type field.
 
@@ -499,9 +552,7 @@
     }
 }
 
-=pod
-
-=item cc_exp
+=head2 cc_exp
 
 This one checks if the input is in the format MM/YY or MM/YYYY and if
 the MM part is a valid month (1-12) and if that date is not in the past.
@@ -528,9 +579,7 @@
     return "$matched_month/$matched_year";
 }
 
-=pod
-
-=item cc_type
+=head2 cc_type
 
 This one checks if the input field starts by M(asterCard), V(isa),
 A(merican express) or D(iscovery).
@@ -543,11 +592,12 @@
     else { return undef; }
 }
 
-=pod
-
-=item ip_address
-
-This checks if the input is formatted like an IP address (v4)
+=head2 ip_address
+
+This checks if the input is formatted like a dotted decimal IP address (v4).
+For other kinds of IP address method, See L<Regexp::Common::net> which provides 
+several more options. L<REGEXP::COMMON SUPPORT> explains how we easily integrate
+with Regexp::Common. 
 
 =cut
 
@@ -570,10 +620,6 @@
 
 __END__
 
-=pod
-
-=back
-
 =head1 REGEXP::COMMON SUPPORT
 
 Data::FormValidator also includes built-in support for using any of regular expressions
@@ -738,9 +784,7 @@
 A few useful methods to use on the Data::FormValidator::Results object are
 available to you to use inside of your routine.
 
-=over 4
-
-=item get_input_data()
+=head3 get_input_data()
 
 Returns the raw input data. This may be a CGI object if that's what 
 was used in the constraint routine. 
@@ -753,7 +797,7 @@
  # tamed to be a hashref, if it wasn't already
  my $data = $self->get_input_data( as_hashref => 1 );
 
-=item get_current_constraint_field
+=head3 get_current_constraint_field()
 
 Returns the name of the current field being tested in the constraint.
 
@@ -766,7 +810,7 @@
 
 For complete examples of multi-valued constraints, see L<Data::FormValidator::Constraints::Upload>
 
-=item get_current_constraint_value
+=head3 get_current_constraint_value()
 
 Returns the name of the current value being tested in the constraint.
 
@@ -777,7 +821,7 @@
 This reduces the number of parameters that need to be passed into the routine
 and allows multi-valued constraints to be used with C<constraint_regexp_map>.
 
-=item get_current_constraint_name
+=head3 get_current_constraint_name()
 
 Returns the name of the current constraint being applied
 
@@ -789,8 +833,17 @@
 It's used internally as part of the interface to the L<Regexp::Commmon>
 regular expressions.
 
-=item name_this
-=item set_current_constraint_name
+=head3 untainted_constaint_value()
+
+   return $dfv->untainted_constraint_value($match);
+
+If you have written a constraint which untaints, use this method to return the
+untainted result. It will prepare the right result whether the user has requested
+untainting or not. 
+
+=head3 name_this()
+
+=head3 set_current_constraint_name()
 
 Sets the name of the current constraint being applied.
 
@@ -812,8 +865,6 @@
 example.
 
 C<name_this> is a provided as a shorter synonym.
-
-=back
 
 The C<meta()> method may also be useful to communicate meta data that
 may have been found. See L<Data::FormValidator::Results> for documentation
@@ -846,16 +897,31 @@
 
 =head1 SEE ALSO
 
-L<Data::FormValidator::Constraints::Upload> - validate the bytes, format and dimensions of file uploads,
-L<Data::FormValidator::Constraints::DateTime> - 
-  A newer DateTime constraint module. May save you a step of tranforming the date into
-  a more useful format after it's validated. 
-L<Data::FormValidator::Constraints::Dates> - the original DFV date constraint module
-L<Regexp::Common> -- lost of useful regular expressions to choose from!
-
-L<Data::FormValidator>
-L<Data::FormValidator::Filters>
-L<Data::FormValidator::ConstraintsFactory>
+=head2 Constraints available in other modules
+
+=over
+
+=item L<Data::FormValidator::Constraints::Upload> - validate the bytes, format and dimensions of file uploads
+
+=item L<Data::FormValidator::Constraints::DateTime> - A newer DateTime constraint module. May save you a step of tranforming the date into a more useful format after it's validated. 
+
+=item L<Data::FormValidator::Constraints::Dates> - the original DFV date constraint module. Try the newer one first!
+
+=item L<Data::FormValidator::Constraints::Japanese> - Japan-specific constraints
+
+=back
+
+=head2 Related modules in this package
+
+=over
+
+=item L<Data::FormValidator::Filters> - transform data before constraints are applied
+
+=item L<Data::FormValidator::ConstraintsFactory> - This is a historical collection of constraints that suffer from cumbersome names. They are worth reviewing though-- C<make_and_constraint> will allow to validate against a list of constraints and shortcircuit if the first one fails. That's perfect if the second constraint depends on the first one having passed.
+
+=item L<Data::FormValidator>
+
+=back
 
 =head1 CREDITS
 

Modified: packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator/Constraints/Upload.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator/Constraints/Upload.pm?rev=3271&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator/Constraints/Upload.pm (original)
+++ packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator/Constraints/Upload.pm Fri Jul 14 19:57:48 2006
@@ -28,7 +28,7 @@
 	image_min_dimensions
 );
 
-$VERSION = 1.1;
+$VERSION = 1.2;
 
 sub file_format {
 	my %params = @_;
@@ -100,6 +100,8 @@
 	## only use filehandle bits for magic data
 	  $fm_mt = $mm->checktype_filehandle($fh) || 
 	    (warn "$0: can't get filehandle for field named $field" and return undef);
+        # Work around a bug in File::MMagic (RT#12074)
+        seek($fh,0,0);
 
 	## fetch mime type universally (or close) 
 	my $uploaded_mt = _get_upload_mime_type($self);

Modified: packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator/Results.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator/Results.pm?rev=3271&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator/Results.pm (original)
+++ packages/libdata-formvalidator-perl/branches/upstream/current/lib/Data/FormValidator/Results.pm Fri Jul 14 19:57:48 2006
@@ -24,7 +24,7 @@
   'bool' => \&_bool_overload_based_on_success,
   fallback => 1;
 
-$VERSION = 4.14;
+$VERSION = 4.30;
 
 =pod
 
@@ -725,6 +725,14 @@
 	return $self->{__CURRENT_CONSTRAINT_NAME};
 }
 
+sub untainted_constraint_value {
+    my $self = shift;
+    my $match = shift;
+
+    return undef unless defined $match;
+    return $self->{__UNTAINT_THIS} ? $match : length $match;
+}
+
 sub set_current_constraint_name {
 	my $self = shift;
 	my $value = shift;
@@ -981,6 +989,10 @@
 sub _constraint_check_match {
 	my 	($self,$c,$params,$untaint_this) = @_;
 	die "_constraint_check_match received wrong number of arguments" unless (scalar @_ == 4);
+
+    # Store whether or not we want untainting in the object so that constraints
+    # can do the right thing conditionally.
+    $self->{__UNTAINT_THIS} = $untaint_this;
 
     my $match = $c->{constraint}->( @$params );
 

Added: packages/libdata-formvalidator-perl/branches/upstream/current/t/FV_length.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/branches/upstream/current/t/FV_length.t?rev=3271&op=file
==============================================================================
--- packages/libdata-formvalidator-perl/branches/upstream/current/t/FV_length.t (added)
+++ packages/libdata-formvalidator-perl/branches/upstream/current/t/FV_length.t Fri Jul 14 19:57:48 2006
@@ -1,0 +1,41 @@
+#!/usr/bin/perl
+use Test::More 'no_plan';
+use strict;
+BEGIN {
+    use_ok('Data::FormValidator'); 
+}
+
+use Data::FormValidator::Constraints qw( 
+    FV_max_length 
+    FV_min_length 
+    FV_length_between
+);
+
+my $result = Data::FormValidator->check({
+         first_names => 'Too long',   
+         keywords    => 'a',
+         ok          => 'Good',
+    },
+    {
+        required => [qw/first_names keywords ok/],
+        constraint_methods => {
+            first_names => FV_max_length(3),
+            keywords    => FV_length_between(5,8),
+            too_long    => FV_min_length(3),  
+            ok          => {
+                constraint_method => FV_length_between(3,6),
+                name => 'ok_length',
+            }
+
+        },
+        msgs => {
+            constraints => {
+                ok_length => 'Not an OK length',
+                length    => 'Wrong Length',
+            }
+        },
+    });
+
+ok(defined $result);
+
+

Modified: packages/libdata-formvalidator-perl/branches/upstream/current/t/regexp_common_closure.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/branches/upstream/current/t/regexp_common_closure.t?rev=3271&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/branches/upstream/current/t/regexp_common_closure.t (original)
+++ packages/libdata-formvalidator-perl/branches/upstream/current/t/regexp_common_closure.t Fri Jul 14 19:57:48 2006
@@ -1,6 +1,6 @@
 # Integration with Regexp::Common;
 
-use Test::More tests => 11;
+use Test::More tests => 13;
 
 use Data::FormValidator; 
 
@@ -8,6 +8,7 @@
 	bad_ip      => '127 0 0 1',
 	good_ip     => '127.0.0.1',
     embedded_ip => 'The address is 127.0.0.1 or something close to that',
+    valid_int   => 0,
 );
 
 my $results;
@@ -16,29 +17,37 @@
 
 eval {
 $results = Data::FormValidator->check(\%FORM, { 
-		required => [qw/good_ip bad_ip/],
+		required => [qw/good_ip bad_ip valid_int/],
 		constraint_method_regexp_map => {
-			qr/_ip$/ => FV_net_IPv4(),
-		}
+			qr/_ip$/  => FV_net_IPv4(),
+		},
+        constraint_methods => {
+            valid_int => FV_num_int(),
+        }
 	});
 };
-ok((not $@), 'runtime errors') or diag $@;
+is($@,'', 'survived eval');
 ok($results->valid->{good_ip}, 'good ip'); 
 ok($results->invalid->{bad_ip}, 'bad ip'); 
+is($results->valid->{valid_int},0, 'zero is valid int');
 
 
 $results = Data::FormValidator->check(\%FORM, { 
 		untaint_all_constraints => 1,
-		required => [qw/good_ip bad_ip/],
+		required => [qw/good_ip bad_ip valid_int/],
 		constraint_method_regexp_map => {
 			qr/_ip$/ => FV_net_IPv4(),
-		}
+		},
+        constraint_methods => {
+            valid_int => FV_num_int(),
+        }
 	});
 
 
-ok((not $@), 'runtime errors') or diag $@;
+is($@,'', 'survived eval');
 ok($results->valid->{good_ip}, 'good ip with tainting'); 
 ok($results->invalid->{bad_ip}, 'bad ip with tainting'); 
+is($results->valid->{valid_int},0, 'zero is valid int with untainting');
 
 # Test passing flags
 $results = Data::FormValidator->check(\%FORM, { 

Modified: packages/libdata-formvalidator-perl/branches/upstream/current/t/untaint.pl
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/branches/upstream/current/t/untaint.pl?rev=3271&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/branches/upstream/current/t/untaint.pl (original)
+++ packages/libdata-formvalidator-perl/branches/upstream/current/t/untaint.pl Fri Jul 14 19:57:48 2006
@@ -4,7 +4,10 @@
 
 use Test::More (tests => 45);
 use Data::FormValidator;
-use Data::FormValidator::Constraints qw/:closures/;
+use Data::FormValidator::Constraints qw/
+    :closures
+    FV_max_length
+/;
 
 # A gift from Andy Lester, this trick shows me where eval's die. 
 use Carp;
@@ -65,9 +68,12 @@
     rules1 => {
 		untaint_constraint_fields => "firstname",
 		required => "firstname",
-		constraints => {
-			firstname => '/^\w{1,15}$/'
-		},
+        # constraints => {
+		# 	firstname => '/^\w{1,15}$/'
+		# },
+        constraint_methods => {
+			firstname => FV_max_length(15),
+        },
 	},
     rules2 => {
 		untaint_constraint_fields => [ qw( lastname email1 )],




More information about the Pkg-perl-cvs-commits mailing list