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;
}
}