| 1 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::Constraint::File; | ||||||||||||||||||||||||||||
| 4 | 2 | $HTML::FormFu::Constraint::File::VERSION = '2.06'; | |||||||||||||||||||||||||||
| 5 | # ABSTRACT: File Upload Constraint | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | extends 'HTML::FormFu::Constraint'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | sub constrain_value { | ||||||||||||||||||||||||||||
| 13 | 4 | ▶ | my ( $self, $value ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
constrain_value: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | return 1 if !defined $value || $value eq ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $value or $value eq ""
MC/DC50%1/2
not defined $value or $value eq ""
not defined $value
$value eq ""
Truth table66%2/3
not(A) or B
A= not defined $valueB= $value eq ""
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 3 | ▶ | return blessed($value) && $value->isa('HTML::FormFu::Upload'); | ||||||||||||||||||||||||||
|
Condition66%2/3
builtin::blessed($value) && $value->isa('HTML::FormFu::Upload')
MC/DC50%1/2
builtin::blessed($value) && $value->isa('HTML::FormFu::Upload')
builtin::blessed($value)
$value->isa('HTML::FormFu::Upload')
Truth table66%2/3
A && B
A= builtin::blessed($value)B= $value->isa('HTML::FormFu::Upload')
| |||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 2 | 1; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | __END__ | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =pod | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head1 NAME | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | HTML::FormFu::Constraint::File - File Upload Constraint | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =head1 VERSION | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | version 2.06 | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | Ensure the submitted value is a file upload. | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | This Constraint is not needed if you use any of the C<File::*> Constraints, | ||||||||||||||||||||||||||||
| 43 | as they all make the same check as this Constraint does. | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =head1 LIMITATIONS | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | This can only verify that your CGI backend (CGI, Catalyst, CGI::Simple) | ||||||||||||||||||||||||||||
| 48 | thinks it was a file upload. If the user submits a filename which doesn't | ||||||||||||||||||||||||||||
| 49 | exist on their system, you will probably get a valid L<HTML::FormFu::Upload> | ||||||||||||||||||||||||||||
| 50 | object, with a valid filehandle, but no Content-Length. This Constraint | ||||||||||||||||||||||||||||
| 51 | would still see this as a valid uploaded file - if you want to ensure that | ||||||||||||||||||||||||||||
| 52 | you get a file with content, instead use | ||||||||||||||||||||||||||||
| 53 | L<HTML::FormFu::Constraint::File::Size> with | ||||||||||||||||||||||||||||
| 54 | L<min|HTML::FormFu::Constraint::File::Size/min> set to C<1>. | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | Is a sub-class of, and inherits methods from L<HTML::FormFu::Constraint> | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | L<HTML::FormFu> | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | Carl Franks, C<cfranks@cpan.org> | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | This library is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 69 | the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | Carl Franks <cpan@fireartist.com> | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | This software is copyright (c) 2018 by Carl Franks. | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 80 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =cut | ||||||||||||||||||||||||||||