lib/HTML/FormFu/QueryType/CGI.pm

filter: Statementstmt 100% 35 / 35 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 50.0% 1 / 2 totaltotal 95.9% 47 / 49 CC 5 SCAR 11.0
CC
5
Cov
98%
parse_uploads
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« lib/HTML/FormFu/Filter/HTMLScrubber.pm ↑ Summary lib/HTML/FormFu/Role/ContainsElements.pm »
1 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::QueryType::CGI;
4 10 $HTML::FormFu::QueryType::CGI::VERSION = '2.09';
5 # ABSTRACT: uploaded file
6  
7 10 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 10 extends 'HTML::FormFu::Upload';
10  
11 10 ▶use HTTP::Headers;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 10 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 21 ▶sub parse_uploads {
Subroutine parse_uploads: called CC=5 SCAR=16.1
Pod undocumented
15 21 my ( $class, $form, $name ) = @_;
16  
17 21 my $query = $form->query;
18 ## CGI wants you to use $query->multi_param($foo).
19 ## doing so breaks CGI::Simple. So shoosh it up for now.
20 21 local $CGI::LIST_CONTEXT_WARN = 0;
21  
22 21 my @params = $query->param($name);
23 21 my @new;
24  
25 21 for my $param (@params) {
26 26 ▶ if ( blessed $param ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($param)) 18 8 26
27 18 my $filename = $param;
28  
29 18 $param = $class->new(
30 { _param => $param,
31 filename => sprintf( "%s", $filename ),
32 parent => $form,
33  
34 # TODO: for now, parent points to the form
35 # pointing to a field will require handling multiple
36 # fields of the same name
37 # if fixed, other QueryTypes and MultiForm will need updating
38 } );
39  
40 my $headers
41 18 = HTTP::Headers->new( %{ $query->uploadInfo($filename) } );
42  
43 18 $param->headers($headers);
44 18 $param->size( $headers->content_length );
45 18 $param->type( $headers->content_type );
46 }
47  
48 26 push @new, $param;
49 }
50  
51 21 ▶ return if !@new;
Branch: 1 branch
BranchTrueFalseTotal
unless @new 0 21 21
52  
53 21 ▶ return @new == 1 ? $new[0] : \@new;
Branch: 1 branch
BranchTrueFalseTotal
@new == 1 ? : 18 3 21
54 }
55  
56 5 ▶sub fh {
Subroutine fh: called CC=1 SCAR=0.0
Pod documented
57 5 my ($self) = @_;
58  
59 5 return $self->_param;
60 }
61  
62 10 __PACKAGE__->meta->make_immutable;
63  
64 10 1;
65  
66 __END__
« lib/HTML/FormFu/Filter/HTMLScrubber.pm ↑ Summary lib/HTML/FormFu/Role/ContainsElements.pm »