r800 - in packages/libdata-formvalidator-perl/trunk: . debian lib/Data lib/Data/FormValidator lib/Data/FormValidator/Constraints t
Gunnar Wolf
gwolf@costa.debian.org
Fri, 18 Mar 2005 01:37:29 +0100
Author: gwolf
Date: 2005-03-18 01:37:28 +0100 (Fri, 18 Mar 2005)
New Revision: 800
Added:
packages/libdata-formvalidator-perl/trunk/t/check_profile_syntax.t
packages/libdata-formvalidator-perl/trunk/t/procedural_valid.t
packages/libdata-formvalidator-perl/trunk/t/unknown.t
Removed:
packages/libdata-formvalidator-perl/trunk/t/10_procedural_valid.t
Modified:
packages/libdata-formvalidator-perl/trunk/Changes
packages/libdata-formvalidator-perl/trunk/MANIFEST
packages/libdata-formvalidator-perl/trunk/META.yml
packages/libdata-formvalidator-perl/trunk/Makefile.PL
packages/libdata-formvalidator-perl/trunk/debian/changelog
packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator.pm
packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Constraints.pm
packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Constraints/Upload.pm
packages/libdata-formvalidator-perl/trunk/t/03_dependency.t
packages/libdata-formvalidator-perl/trunk/t/24_upload.t
packages/libdata-formvalidator-perl/trunk/t/upload_post_text.txt
Log:
New upstream version 3.63
Modified: packages/libdata-formvalidator-perl/trunk/Changes
===================================================================
--- packages/libdata-formvalidator-perl/trunk/Changes 2005-03-18 00:33:33 UTC (rev 799)
+++ packages/libdata-formvalidator-perl/trunk/Changes 2005-03-18 00:37:28 UTC (rev 800)
@@ -1,3 +1,28 @@
+3.63
+ [BUG FIXES]
+ - email validation was beefed up to not permit spaces with e-mails
+ or semi-colons to get through. Thanks to Jason Crome for some tests
+ to this, and the Mail::VRFY module, which was the source of the
+ improved RE.
+
+ [INTERNALS]
+ - Added a couple more test to the distribution which were missing in
+ the MANIFEST
+
+3.62 Fri Oct 8 22:55:49 EST 2004
+ [INTERNALS]
+ - Removed experimental label from 'msgs' functionality.
+ - Beefed up test suite for dependencies and dependency_groups (Drew Taylor)
+
+3.61 Mon Sep 20 18:10:23 EST 2004
+ [BUG FIXES]
+ - file_format from ::Constraints::Upload now handles non-existent files more
+ gracefully. (Evan A. Zacks)
+
+3.60 Mon Sep 20 18:10:23 EST 2004
+ [BUG FIXES]
+ - file_max_bytes seemed to never be reporting failure.
+
3.59 Thu Jul 02 2004
[ENHANCEMENTS]
- Added more tests for Date constraints, and removed some more warnings (Michael Dorman)
Modified: packages/libdata-formvalidator-perl/trunk/MANIFEST
===================================================================
--- packages/libdata-formvalidator-perl/trunk/MANIFEST 2005-03-18 00:33:33 UTC (rev 799)
+++ packages/libdata-formvalidator-perl/trunk/MANIFEST 2005-03-18 00:37:28 UTC (rev 800)
@@ -22,7 +22,7 @@
t/07_missing_optional.t
t/08_profile_checking.t
t/09_require_some.t
-t/10_procedural_valid.t
+t/procedural_valid.t
t/11_procedural_match.t
t/12_untaint.pl
t/12_untaint.t
@@ -52,3 +52,7 @@
t/constraints_reuse.t
test/00_base.badformat
test/00_base.profile
+t/check_profile_syntax.t
+t/unknown.t
+
+
Modified: packages/libdata-formvalidator-perl/trunk/META.yml
===================================================================
--- packages/libdata-formvalidator-perl/trunk/META.yml 2005-03-18 00:33:33 UTC (rev 799)
+++ packages/libdata-formvalidator-perl/trunk/META.yml 2005-03-18 00:37:28 UTC (rev 800)
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Data-FormValidator
-version: 3.59
+version: 3.63
license: perl
distribution_type: module
requires:
@@ -16,16 +16,16 @@
provides:
Data::FormValidator:
file: lib/Data/FormValidator.pm
- version: 3.59
+ version: 3.63
Data::FormValidator::Constraints:
file: lib/Data/FormValidator/Constraints.pm
- version: 3.5
+ version: 3.63
Data::FormValidator::Constraints::Dates:
file: lib/Data/FormValidator/Constraints/Dates.pm
version: 0.03
Data::FormValidator::Constraints::Upload:
file: lib/Data/FormValidator/Constraints/Upload.pm
- version: 0.62
+ version: 0.71
Data::FormValidator::ConstraintsFactory:
file: lib/Data/FormValidator/ConstraintsFactory.pm
version: 1.3
Modified: packages/libdata-formvalidator-perl/trunk/Makefile.PL
===================================================================
--- packages/libdata-formvalidator-perl/trunk/Makefile.PL 2005-03-18 00:33:33 UTC (rev 799)
+++ packages/libdata-formvalidator-perl/trunk/Makefile.PL 2005-03-18 00:37:28 UTC (rev 800)
@@ -4,7 +4,7 @@
WriteMakefile
(
NAME => 'Data::FormValidator',
- VERSION => '3.59',
+ VERSION => '3.63',
PL_FILES => {},
INSTALLDIRS => 'site',
PREREQ_PM => {
Modified: packages/libdata-formvalidator-perl/trunk/debian/changelog
===================================================================
--- packages/libdata-formvalidator-perl/trunk/debian/changelog 2005-03-18 00:33:33 UTC (rev 799)
+++ packages/libdata-formvalidator-perl/trunk/debian/changelog 2005-03-18 00:37:28 UTC (rev 800)
@@ -1,3 +1,9 @@
+libdata-formvalidator-perl (3.63-1) unstable; urgency=low
+
+ * New upstream release
+
+ -- Gunnar Wolf <gwolf@debian.org> Thu, 17 Mar 2005 18:34:45 -0600
+
libdata-formvalidator-perl (3.59-1) unstable; urgency=low
* New upstream release
Modified: packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Constraints/Upload.pm
===================================================================
--- packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Constraints/Upload.pm 2005-03-18 00:33:33 UTC (rev 799)
+++ packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Constraints/Upload.pm 2005-03-18 00:37:28 UTC (rev 800)
@@ -20,7 +20,7 @@
valid_file_max_bytes
);
-$VERSION = '0.62';
+$VERSION = '0.71';
sub valid_file_format {
my $self = shift;
@@ -69,7 +69,7 @@
use MIME::Types;
my $mimetypes = MIME::Types->new;
my MIME::Type $t = $mimetypes->type($mt);
- my @mt_exts = $t->extensions;
+ my @mt_exts = $t ? $t->extensions : ();
my ($uploaded_ext) = ($img =~ m/\.([\w\d]*)?$/);
@@ -152,7 +152,13 @@
Check that you used 'constraint_method' and not 'constraint'";
my $max_bytes_ref = shift;
- my $max_bytes = $max_bytes_ref || 1024*1024; # default to 1 Meg
+ my $max_bytes;
+ if ((ref $max_bytes_ref) and defined $$max_bytes_ref) {
+ $max_bytes = $$max_bytes_ref;
+ }
+ else {
+ $max_bytes = 1024*1024; # default to 1 Meg
+ }
my $q = $self->get_input_data;
require UNIVERSAL;
Modified: packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Constraints.pm
===================================================================
--- packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Constraints.pm 2005-03-18 00:33:33 UTC (rev 799)
+++ packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Constraints.pm 2005-03-18 00:37:28 UTC (rev 800)
@@ -24,7 +24,7 @@
use strict;
use vars qw/$AUTOLOAD @ISA @EXPORT_OK %EXPORT_TAGS $VERSION/;
-$VERSION = 3.50;
+$VERSION = 3.63;
require Exporter;
@ISA = qw(Exporter);
@@ -156,10 +156,12 @@
sub match_email {
my $email = shift;
- if ($email =~ /^([\040-\176]+\@[-A-Za-z0-9.]+\.[A-Za-z]+)$/) {
- return $1;
+ if ($email =~ /^(([a-z0-9_\.\+\-\=\?\^\#]){1,64}\@(([a-z0-9\-]){1,251}\.){1,252}[a-z0-9]{2,4})$/i) {
+ return $1;
}
- else { return undef; }
+ else {
+ return undef;
+ }
}
my $state = <<EOF;
Modified: packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator.pm
===================================================================
--- packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator.pm 2005-03-18 00:33:33 UTC (rev 799)
+++ packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator.pm 2005-03-18 00:37:28 UTC (rev 800)
@@ -31,7 +31,7 @@
use vars qw( $VERSION $AUTOLOAD @ISA @EXPORT_OK %EXPORT_TAGS );
-$VERSION = '3.59';
+$VERSION = '3.63';
require Exporter;
@ISA = qw(Exporter);
Modified: packages/libdata-formvalidator-perl/trunk/t/03_dependency.t
===================================================================
--- packages/libdata-formvalidator-perl/trunk/t/03_dependency.t 2005-03-18 00:33:33 UTC (rev 799)
+++ packages/libdata-formvalidator-perl/trunk/t/03_dependency.t 2005-03-18 00:37:28 UTC (rev 800)
@@ -1,60 +1,105 @@
-
use strict;
$^W = 1;
-use Test::More tests => 7;
-
+use Test::More tests => 23;
use Data::FormValidator;
+# test profile
my $input_profile = {
- required => [qw(bar)],
- optional => [qw(foo)],
dependencies => {
- cc_type => {
- Check => [qw( cc_num )],
- Visa => [qw( cc_num cc_exp cc_name )],
+ pay_type => {
+ Check => [qw( cc_num )],
+ Visa => [qw( cc_num cc_exp cc_name )],
},
},
};
+my $input_hashref = {pay_type=>'Visa'};
-my $validator = new Data::FormValidator({default => $input_profile});
-my $input_hashref = {
- cc_type=>'Visa'
- };
+##
+## Validate a complex dependency
+##
+
+##
+## validate()
+
my ($valids, $missings, $invalids, $unknowns);
-
+my $validator = Data::FormValidator->new({default => $input_profile});
eval{
($valids, $missings, $invalids, $unknowns) = $validator->validate($input_hashref, 'default');
};
-ok(not $@);
+ok(!$@, "no eval problems");
my %missings = map {$_ => 1} @$missings;
-ok($missings{'cc_num'});
-ok($missings{'cc_exp'});
+ok($missings{cc_num}, "missing cc_num");
+ok($missings{cc_exp}, "missing cc_exp");
+ok($missings{cc_name}, "missing cc_name");
-$input_hashref = {
- cc_type=>'Check'
- };
+##
+## check()
+
+my $result;
+eval {
+ $result = $validator->check($input_hashref, 'default');
+};
+
+ok(!$@, "no eval problems");
+isa_ok($result, "Data::FormValidator::Results", "returned object");
+
+ok($result->has_missing, "has_missing returned true");
+ok($result->missing('cc_num'), "missing('cc_num') returned true");
+ok($result->missing('cc_exp'), "missing('cc_exp') returned true");
+ok($result->missing('cc_name'), "missing('cc_name') returned true");
+
+
+
+##
+## validate()
+
+$input_hashref = {pay_type=>'Check'
+ };
+
eval{
($valids, $missings, $invalids, $unknowns) = $validator->validate($input_hashref, 'default');
};
-ok(not $@);
+ok(!$@, "no eval problems");
%missings = map {$_ => 1} @$missings;
-ok($missings{'cc_num'});
-ok(not $missings{'cc_exp'});
+ok($missings{cc_num}, 'missing cc_num');
+ok(!$missings{cc_exp}, 'not missing cc_exp');
+ok(!$missings{cc_name}, 'not missing cc_name');
+
+##
+## check()
+
+$result = undef;
+eval {
+ $result = $validator->check($input_hashref, 'default');
+};
+
+ok(!$@, "no eval problems");
+isa_ok($result, "Data::FormValidator::Results", "returned object");
+
+ok($result->has_missing, "has_missing returned true");
+ok($result->missing('cc_num'), "missing('cc_num') returned true");
+is($result->missing('cc_exp'), undef, "missing('cc_exp') returned false");
+is($result->missing('cc_name'), undef, "missing('cc_name') returned false");
+
+
+
## Now, some tests using a CGI.pm object as input
use CGI;
-my $q = CGI->new('cc_type=Visa');
+my $q = CGI->new('pay_type=Visa');
my $results;
eval {
- $results = $validator->check($input_hashref,'default');
+ $results = $validator->check($q, 'default');
};
ok($results->missing('cc_num'), 'using CGI.pm object for input');
+is($result->missing('cc_exp'), undef, "missing('cc_exp') returned false");
+is($result->missing('cc_name'), undef, "missing('cc_name') returned false");
Deleted: packages/libdata-formvalidator-perl/trunk/t/10_procedural_valid.t
===================================================================
--- packages/libdata-formvalidator-perl/trunk/t/10_procedural_valid.t 2005-03-18 00:33:33 UTC (rev 799)
+++ packages/libdata-formvalidator-perl/trunk/t/10_procedural_valid.t 2005-03-18 00:37:28 UTC (rev 800)
@@ -1,72 +0,0 @@
-use strict;
-#Check that the valid_* routines are nominally working.
-
-$^W = 1;
-
-use Test::More tests => 26;
-
-use Data::FormValidator qw(:validators :matchers);
-
-
-
-my $invalid = "fake value";
-
-#For CC Exp test
-my @time = localtime(time);
-
-my %tests = (
- valid_american_phone => "555-555-5555",
- valid_cc_exp => "10/" . sprintf("%.2d", ($time[5] - 99)),
- valid_cc_type => "MasterCard",
- valid_email => 'foo@domain.com',
- valid_ip_address => "64.58.79.230",
- valid_phone => "123-456-7890",
- valid_postcode => "T2N 0E6",
- valid_province => "NB",
- valid_state => "CA",
- valid_state_or_province => "QC",
- valid_zip => "94112",
- valid_zip_or_postcode => "50112",
-);
-
-my $i = 1;
-
-foreach my $function (keys(%tests)) {
- my $rv;
- my $val = $tests{$function};
- my $is_valid = "\$rv = $function('$val');";
- my $not_valid = "\$rv = $function('$invalid');";
-
- eval $is_valid;
- ok(not $@ and $rv == 1) or
- diag $@;
- #diag sprintf("%-25s using %-16s", $function, "(valid value)");
- $i++;
-
- eval $not_valid;
- ok(not $@ and not $rv) or
- diag sprintf("%-25s using %-16s", $function, "(invalid value)");
- $i++;
-}
-
-#Test cc_number seperately since i do not know a valid cc number
-{
- my $rv;
- eval "\$rv = valid_cc_number('$invalid', 'm')";
-
- ok(not $@ and not $rv) or
- diag sprintf("%-25s using %-16s", "valid_cc_number", "(invalid value)");
-}
-
-$i++;
-
-#Test fake validation routine
-{
- my $rv;
- eval "\$rv = valid_foobar('$invalid', 'm')";
-
- ok($@) or
- diag sprintf("%-25s", "Fake Valid Routine");
-}
-
-
Modified: packages/libdata-formvalidator-perl/trunk/t/24_upload.t
===================================================================
--- packages/libdata-formvalidator-perl/trunk/t/24_upload.t 2005-03-18 00:33:33 UTC (rev 799)
+++ packages/libdata-formvalidator-perl/trunk/t/24_upload.t 2005-03-18 00:37:28 UTC (rev 800)
@@ -1,8 +1,9 @@
#########################
-use Test::More tests => 17;
+use Test::More tests => 18;
+use strict;
BEGIN {
- use_ok(CGI);
+ use_ok('CGI');
use_ok('Data::FormValidator::Constraints::Upload')
};
@@ -15,7 +16,7 @@
'HTTP_CONNECTION' => 'TE, close',
'REQUEST_METHOD' => 'POST',
'SCRIPT_URI' => 'http://www.perl.org/test.cgi',
- 'CONTENT_LENGTH' => '2986',
+ 'CONTENT_LENGTH' => 3129,
'SCRIPT_FILENAME' => '/home/usr/test.cgi',
'SERVER_SOFTWARE' => 'Apache/1.3.27 (Unix) ',
'HTTP_TE' => 'deflate,gzip;q=0.3',
@@ -41,17 +42,21 @@
binmode(IN);
*STDIN = *IN;
-$q = new CGI;
+my $q = new CGI;
use Data::FormValidator;
my $default = {
- required=>[qw/hello_world 100x100_gif 300x300_gif/],
+ required=>[qw/hello_world does_not_exist_gif 100x100_gif 300x300_gif/],
validator_packages=> 'Data::FormValidator::Constraints::Upload',
constraints => {
'hello_world' => {
constraint_method => 'file_format',
params=>[],
},
+ 'does_not_exist_gif' => {
+ constraint_method => 'file_format',
+ params=>[],
+ },
'100x100_gif' => [
{
constraint_method => 'file_format',
@@ -82,10 +87,13 @@
my $missing = $results->missing;
-# Test to make sure hello world failes because it is the wrong type
-ok((grep /hello_world/, @invalids), 'expect format failure');
+# Test to make sure hello world fails because it is the wrong type
+ok((grep {m/hello_world/} @invalids), 'expect format failure');
+# should fail on empty/missing source file data
+ok((grep {m/does_not_exist_gif/} @invalids), 'expect non-existent failure');
+
# Make sure 100x100 passes because it is the right type and size
ok(exists $valid->{'100x100_gif'});
@@ -96,7 +104,7 @@
ok($meta->{mime_type}, 'setting mime_type meta data');
# 300x300 should fail because it is too big
-ok((grep {'300x300'} @invalids), 'max_bytes');
+ok((grep {m/300x300/} @invalids), 'max_bytes');
ok($results->meta('100x100_gif')->{bytes}>0, 'setting bytes meta data');
@@ -150,6 +158,10 @@
($valid,$missing,$invalid) = $dfv->validate($q, 'profile_3');
ok(exists $valid->{'100x100_gif'}, 'expecting success with max_dimensions using constraint_regexp_map');
-ok((grep /300x300/, @$invalid), 'expecting failure with max_dimensions using constraint_regexp_map');
+#use Data::Dumper;
+#warn Dumper ($invalid);
+ok((grep {m/300x300/} @$invalid), 'expecting failure with max_dimensions using constraint_regexp_map');
+
+
Copied: packages/libdata-formvalidator-perl/trunk/t/check_profile_syntax.t (from rev 799, packages/libdata-formvalidator-perl/branches/upstream/current/t/check_profile_syntax.t)
Copied: packages/libdata-formvalidator-perl/trunk/t/procedural_valid.t (from rev 799, packages/libdata-formvalidator-perl/branches/upstream/current/t/procedural_valid.t)
Copied: packages/libdata-formvalidator-perl/trunk/t/unknown.t (from rev 799, packages/libdata-formvalidator-perl/branches/upstream/current/t/unknown.t)
Modified: packages/libdata-formvalidator-perl/trunk/t/upload_post_text.txt
===================================================================
(Binary files differ)