Skip Menu |
 

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

Maintainer(s)' notes

This is the bug queue for Data::FormValidator.

Report information
The Basics
Id: 75243
Status: open
Priority: 0/
Queue: Data-FormValidator

People
Owner: Nobody in particular
Requestors: karavelov [...] mail.bg
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 4.66
Fixed in: (no value)



Subject: string filters and references
Download (untitled) / with headers
text/plain 615b
In Data::FormValidator::Filters all string filters like 'filter_trim', 'filter_strip' etc. should check if the value is reference and do nothing if it is. I find convenient to define trim & strip as default filters for web-form data, but they break upload fields because they are double values: scalar string (filename) + Fh reference. Filtering the scalar value creates new value with modified string content and no Fh reference. This leads to subtle bug that manifests only on some uploads with specially named files. My experience is with DFV 4.66 and perl 5.10.1 Thanks in advance and best regards luben
Subject: Re: [rt.cpan.org #75243] string filters and references
Date: Thu, 23 Feb 2012 13:23:11 -0500
To: bug-Data-FormValidator [...] rt.cpan.org
From: Mark Stosberg <mark [...] summersault.com>
Patch welcome.
Subject: Re: [rt.cpan.org #75243] string filters and references
Date: Thu, 23 Feb 2012 21:58:09 +0200
To: bug-Data-FormValidator [...] rt.cpan.org
From: karavelov [...] mail.bg
Download (untitled) / with headers
text/plain 1.1k
----- Цитат от mark@summersault.com via RT (bug-Data-FormValidator@rt.cpan.org), на 23.02.2012 в 20:23 ----- Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=75243 > > > Patch welcome. >
Here it is. I seems that only trim and strip could benefit, the other text filters are not meant for global application. --- lib/Data/FormValidator/Filters.pm | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/lib/Data/FormValidator/Filters.pm b/lib/Data/FormValidator/Filters.pm index 108b23c..836a6ea 100644 --- a/lib/Data/FormValidator/Filters.pm +++ b/lib/Data/FormValidator/Filters.pm @@ -173,6 +173,7 @@ Remove white space at the front and end of the fields. sub filter_trim { my $value = shift; return unless defined $value; + return $value if ref $value; # Remove whitespace at the front $value =~ s/^s+//o; @@ -194,6 +195,7 @@ Runs of white space are replaced by a single space. sub filter_strip { my $value = shift; return unless defined $value; + return $value if ref $value; # Strip whitespace $value =~ s/s+/ /g; -- -- Luben Karavelov
Subject: Re: [rt.cpan.org #75243] string filters and references
Date: Mon, 27 Feb 2012 09:38:57 -0500
To: bug-Data-FormValidator [...] rt.cpan.org
From: Mark Stosberg <mark [...] summersault.com>
Download (untitled) / with headers
text/plain 332b
Show quoted text
> Here it is. > I seems that only trim and strip could benefit, the other text filters are not meant for global application.
I agree. The patch looked good. Could you also add some automated tests for it is well? That would be helpful. You will receive credit to "Luben Karavelov" in "Changes" in the next release. Mark
Download (untitled) / with headers
text/plain 498b
On Mon Feb 27 09:39:07 2012, mark@summersault.com wrote: Show quoted text
> > The patch looked good. Could you also add some automated tests for it > is > well? That would be helpful. > > You will receive credit to "Luben Karavelov" in "Changes" in the next > release. > > Mark
I have tried to make doublevar that is Fh and string at the same time but without any success. Without it the tests are pointless. I will look further in CGI.pm sources in order to find how it is done and write the tests. Luben
Subject: Re: [rt.cpan.org #75243] string filters and references
Date: Wed, 29 Feb 2012 13:08:59 -0500
To: bug-Data-FormValidator [...] rt.cpan.org
From: Mark Stosberg <mark [...] summersault.com>
Download (untitled) / with headers
text/plain 499b
Show quoted text
> I have tried to make doublevar that is Fh and string at the same time but without > any success. Without it the tests are pointless. I will look further in CGI.pm sources > in order to find how it is done and write the tests.
Luben, Thanks for looking. You'll get it soon. In CGI.pm, jump down to here in the source: package Fh; Perhaps the missing key is the use over overloading with "use overload" which can cause an object to behave differently when used in a "string" context. Mark


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.