Skip Menu |
 

This queue is for tickets about the WWW-Form CPAN distribution.

Report information
The Basics
Id: 129817
Status: new
Priority: 0/
Queue: WWW-Form

People
Owner: Nobody in particular
Requestors: HOUSTON [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.19
Fixed in: (no value)



Subject: REGEX_MATCH fails on input "0"
Download (untitled) / with headers
text/plain 612b
The WWW::FieldValidator::REGEX_MATCH fails when the input is "0" - see the attached test case. This is because the test at line 138 only tests against truth rather than definedness. The trivial patch is: --- lib/WWW/FieldValidator.pm.orig 2019-06-13 22:29:23.770954118 +0100 +++ lib/WWW/FieldValidator.pm 2019-06-13 22:30:18.458767185 +0100 @@ -135,7 +135,7 @@ # Checks to see if input matches the specified pattern. sub _validateRegex { my $self = shift; - my $input = shift || ''; + my $input = shift // ''; return ($input =~ /$self->{regex}/); } although that's 5.10 syntax, of course.
Subject: wfv.t
Download wfv.t
text/x-perl 525b
use strict; use warnings; use Test::More tests => 11; use WWW::FieldValidator; my $validator = WWW::FieldValidator->new ( WWW::FieldValidator::REGEX_MATCH, 'Value must be 0 to 5', '^[0-5]$' ); ok !$validator->validate ('donkey'), 'Not donkey'; ok !$validator->validate (''), 'Not empty string'; ok !$validator->validate ('55'), 'Not double digit'; ok !$validator->validate ('-5'), 'Not negative int'; for my $data (0..5) { ok $validator->validate ($data), "$data is fine"; } ok !$validator->validate ('6'), 'Not 6';


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.