Skip Menu |

This queue is for tickets about the FormValidator-Simple CPAN distribution.

Report information
The Basics
Id: 27212
Status: open
Priority: 0/
Queue: FormValidator-Simple

People
Owner: Nobody in particular
Requestors: chris+rt [...] chrisdolan.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 0.23
  • 0.21
  • 0.22
  • 0.28
Fixed in: (no value)



Subject: [PATCH] False-but-defined data field ignored when returned from constraint plugin
[This bug is actually against v0.22, but RT doesn't seem to know about that version] I have a FormValidator::Simple plugin that rejects input that has Unicode characters that are non-printable. If such characters are detected, the input is replaced with an empty string instead, so that I don't hand bad data back to the HTML form that will be sent to the user. Here's my code: sub PRINTABLE { my ($self, $params, $args) = @_; my $string = $params->[0]; $string =~ s/\t//gxms; # allowed characters that are in \p{C} # see 'perldoc perlunicode' # \p{C} == "Other" # \p{Zl} == "LineSeparator" # \p{Zp} == "ParagraphSeparator" return (FAIL, q{}) if $string =~ m/\p{C}|\p{Zl}|\p{Zp}/xms; return SUCCESS; } However, the q{} empty string is false, so FormValidator::Simple ignores it and leaves the rejected string. The following trivial patch fixes this for me: --- /Users/chris/perl/lib/perl5/site_perl/FormValidator/Simple.pm 2007-03-06 05:11:15.000000000 -0600 +++ inc/FormValidator/Simple.pm 2007-05-20 20:41:49.000000000 -0500 @@ -152,7 +152,7 @@ $self->results->set_result($name, $constraint->name, $result); - $self->results->record($name)->data($data) if $data; + $self->results->record($name)->data($data) if defined $data; } }
Hi, This problem still exists in 0.23. This fix (included below) is VERY trivial and obvious. Would you please include it in the next release? As is, I have to put a patched copy of FormValidator/Simple.pm in my inc/ to work around this problem. Thanks! Chris On Sun May 20 21:49:20 2007, CDOLAN wrote: Show quoted text
> [This bug is actually against v0.22, but RT doesn't seem to know about > that version] > > I have a FormValidator::Simple plugin that rejects input that has > Unicode characters that are non-printable. If such characters are > detected, the input is replaced with an empty string instead, so that I > don't hand bad data back to the HTML form that will be sent to the user. > Here's my code: > > sub PRINTABLE { > my ($self, $params, $args) = @_; > my $string = $params->[0]; > $string =~ s/\t//gxms; # allowed characters that are in \p{C} > > # see 'perldoc perlunicode' > > # \p{C} == "Other" > > # \p{Zl} == "LineSeparator" > > # \p{Zp} == "ParagraphSeparator" > > return (FAIL, q{}) if $string =~ m/\p{C}|\p{Zl}|\p{Zp}/xms; > return SUCCESS; > } > > However, the q{} empty string is false, so FormValidator::Simple ignores > it and leaves the rejected string. The following trivial patch fixes > this for me: > > --- /Users/chris/perl/lib/perl5/site_perl/FormValidator/Simple.pm > 2007-03-06 05:11:15.000000000 -0600 > +++ inc/FormValidator/Simple.pm 2007-05-20 20:41:49.000000000 -0500 > @@ -152,7 +152,7 @@ > > $self->results->set_result($name, $constraint->name,
$result); Show quoted text
> > - $self->results->record($name)->data($data) if $data; > + $self->results->record($name)->data($data) if defined $data; > } > > }
Hi, This is still broken in 0.28. The fix is incredibly simple (just add "defined " to one line of code. Will you please make this trivial change and release a new version? Chris On Mon May 26 15:32:36 2008, CDOLAN wrote: Show quoted text
> Hi, > > This problem still exists in 0.23. This fix (included below) is VERY > trivial and obvious. Would you please include it in the next release? > As is, I have to put a patched copy of FormValidator/Simple.pm in my > inc/ to work around this problem. > > Thanks! > Chris > > On Sun May 20 21:49:20 2007, CDOLAN wrote:
> > [This bug is actually against v0.22, but RT doesn't seem to know about > > that version] > > > > I have a FormValidator::Simple plugin that rejects input that has > > Unicode characters that are non-printable. If such characters are > > detected, the input is replaced with an empty string instead, so that I > > don't hand bad data back to the HTML form that will be sent to the user. > > Here's my code: > > > > sub PRINTABLE { > > my ($self, $params, $args) = @_; > > my $string = $params->[0]; > > $string =~ s/\t//gxms; # allowed characters that are in \p{C} > > > > # see 'perldoc perlunicode' > > > > # \p{C} == "Other" > > > > # \p{Zl} == "LineSeparator" > > > > # \p{Zp} == "ParagraphSeparator" > > > > return (FAIL, q{}) if $string =~ m/\p{C}|\p{Zl}|\p{Zp}/xms; > > return SUCCESS; > > } > > > > However, the q{} empty string is false, so FormValidator::Simple ignores > > it and leaves the rejected string. The following trivial patch fixes > > this for me: > > > > --- /Users/chris/perl/lib/perl5/site_perl/FormValidator/Simple.pm > > 2007-03-06 05:11:15.000000000 -0600 > > +++ inc/FormValidator/Simple.pm 2007-05-20 20:41:49.000000000 -0500 > > @@ -152,7 +152,7 @@ > > > > $self->results->set_result($name, $constraint->name,
> $result);
> > > > - $self->results->record($name)->data($data) if $data; > > + $self->results->record($name)->data($data) if defined
$data; Show quoted text
> > } > > > > }
> >