NAME
Egg::Plugin::Filter - Plugin to regularize input data.
SYNOPSIS
use Egg qw/ Filter /;
# The received form data is filtered.
$e->filter(
myname => [qw/ hold_html abs_strip trim /],
address=> [qw/ hold_html crlf:2 abs_strip trim /],
tel => [qw/ hold phone /],
);
# Cookie is filtered.
my $cookie= $e->filter( {
nick_name=> [qw/ strip_html abs_strip trim /],
email => [qw/ hold_html hold /],
}, $e->request->cookies );
DESCRIPTION
It is a plugin target to remove the problem part from data input to the form.
An original filter can be defined in %Filters.
package MyApp;
use Egg qw/ Filter /;
{
my $filter= \%Egg::Plugin::Filter::Filters;
$filter->{myfilter}= sub {
my($e, $value, $arg)= @_;
..........
...
};
};
Those filters cannot be used when overwriting because the filter of default is defined in %Filters beforehand.
The name of the defined key becomes the name of the filter.
The object of the project and the value of the object parameter are passed for the set CODE reference. Moreover, when it is being made to have in the argument by the filter, it is passed by the third element.
There is especially no return value needing.
METHODS
filter ( [ATTR_HASH], [PARAM_HASH] )
The filter is processed.
ATTR_HASH is a filter setting, and the key is a name of the processed parameter. The value enumerates the name of the filter with ARRAY.
$e->filter(
param_name1 => [qw/ strip space trim /],
param_name2 => [qw/ strip_html space trim /],
param_name3 => [qw/ strip_html crlf:3 trim /],
);
The thing that connects the values of the parameter and processes it can be done.
$e->filter(
'anyparam[qw/ param_name1 param_name2 /]' => [qw/ strip space trim /],
);
It is processed being made 'anyparam' to connect 'param_name1' and 'param_name2' by this.
When the argument can be given to the filter, the argument can be passed according to points like the connection of parameters.
$e->filter(
param1 => ["regex['^\s+', '\s+$]"],
);
The processed parameter is passed to PARAM_HASH. When this is unspecification, $e->request->params is used.
FILTERS
trim
The space character in the back and forth is deleted.
hold
The space character is completely deleted.
hold_crlf
It is 'hold' in the object only as for changing line and the tab.
hold_tab
The tab is deleted.
hold_blank
Consecutive half angle space is settled in one.
Alias is 'hold_space'.
hold_html
The character string seen the HTML tag is deleted.
strip
The continuousness of the space character is substituted for one half angle space.
strip_blank
The continuousness of half angle space is substituted for one half angle space.
Alias is 'strip_space'.
strip_tab
Continuousness in the tab is substituted for one half angle space.
strip_html
The character string seen the HTML tag is substituted for one half angle space.
strip_crlf
It is 'strip' for changing line and the tab.
crlf [NUM]
A consecutive changing line is settled in NUM piece. The tab is deleted.
Default when NUM is omitted is 2.
param1 => [qw/ crlf[3] /]
escape_html
It is 'encode_entities' of HTML::Entities.
digit
It deletes it excluding the normal-width figure.
alphanum
It deletes it excluding the alphanumeric character.
integer
It deletes it excluding the integer.
pos_integer
It deletes it excluding the positive integer.
neg_integer
It deletes it excluding the negative integer.
decimal
It deletes it excluding the integer including small number of people.
pos_decimal
It deletes it excluding a positive integer including small number of people.
neg_decimal
It deletes it excluding a negative integer including small number of people.
dollars
It deletes it excluding the figure that can be used with dollar currency.
phone
The character that cannot be used by the telephone number is deleted.
sql_wildcard
'*' is substituted for '%'.
quotemeta
Quotemeta is done.
uc
uc is done.
ucfirst
ucfirst is done.
lc
lc is done.
lc_email
The domain name part in the mail address is converted into the small letter.
MyName@DOMAIN.COM => MyName@domain.com
Alias is 'email'.
uri
The domain name part of URL is converted into the small letter.
http://MYDOMAIN.COM/Hoge/Boo.html => http://mydomain.com/Hoge/Boo.html
Alias is 'url'.
regex ([REGEXP])
The part that matches to the regular expression specified for REGEXP is deleted. REGEXP is two or more contact.
param1 => ["regex['abc', 'xyz']"],
SEE ALSO
Egg::Release, HTML::Entities, URI,
AUTHOR
Masatoshi Mizuno <lushe@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2008 Bee Flag, Corp. <http://egg.bomcity.com/>.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.