line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Controller::DBIC::API::Validator::Visitor; |
2
|
|
|
|
|
|
|
$Catalyst::Controller::DBIC::API::Validator::Visitor::VERSION = '2.008001'; |
3
|
|
|
|
|
|
|
#ABSTRACT: Provides validation services for inbound requests against whitelisted parameters |
4
|
16
|
|
|
16
|
|
120
|
use Moose; |
|
16
|
|
|
|
|
43
|
|
|
16
|
|
|
|
|
111
|
|
5
|
16
|
|
|
16
|
|
103000
|
use namespace::autoclean; |
|
16
|
|
|
|
|
53
|
|
|
16
|
|
|
|
|
170
|
|
6
|
|
|
|
|
|
|
|
7
|
16
|
|
|
16
|
|
1485
|
BEGIN { extends 'Data::DPath::Validator::Visitor'; } |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
16
|
|
50
|
16
|
|
8876586
|
use constant DEBUG => $ENV{DATA_DPATH_VALIDATOR_DEBUG} || 0; |
|
16
|
|
|
|
|
79
|
|
|
16
|
|
|
|
|
9875
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
around visit_array => sub { |
13
|
|
|
|
|
|
|
my ( $orig, $self, $array ) = @_; |
14
|
|
|
|
|
|
|
$self->dive(); |
15
|
|
|
|
|
|
|
warn 'ARRAY: ' . $self->current_template if DEBUG; |
16
|
|
|
|
|
|
|
if ( @$array == 1 && $array->[0] eq '*' ) { |
17
|
|
|
|
|
|
|
$self->append_text('[reftype eq "HASH" ]'); |
18
|
|
|
|
|
|
|
$self->add_template( $self->current_template ); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
else { |
21
|
|
|
|
|
|
|
if ( $self->current_template =~ /\/$/ ) { |
22
|
|
|
|
|
|
|
my $temp = $self->current_template; |
23
|
|
|
|
|
|
|
$self->reset_template(); |
24
|
|
|
|
|
|
|
$temp =~ s/\/$//; |
25
|
|
|
|
|
|
|
$self->append_text($temp); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
$self->$orig($array); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
$self->rise(); |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub visit_array_entry { |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# to make release-unused-vars.t happy |
35
|
|
|
|
|
|
|
#my ($self, $elem, $index, $array) = @_; |
36
|
92
|
|
|
92
|
1
|
7666
|
my ( $self, $elem ) = @_; |
37
|
92
|
|
|
|
|
326
|
$self->dive(); |
38
|
92
|
|
|
|
|
12603
|
warn 'ARRAYENTRY: ' . $self->current_template if DEBUG; |
39
|
92
|
100
|
|
|
|
375
|
if ( !ref($elem) ) { |
|
|
50
|
|
|
|
|
|
40
|
69
|
|
|
|
|
2645
|
$self->append_text( $elem . '/*' ); |
41
|
69
|
|
|
|
|
2907
|
$self->add_template( $self->current_template ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
elsif ( ref($elem) eq 'HASH' ) { |
44
|
23
|
|
|
|
|
173
|
$self->visit($elem); |
45
|
|
|
|
|
|
|
} |
46
|
92
|
|
|
|
|
9928
|
$self->rise(); |
47
|
92
|
|
|
|
|
19800
|
$self->value_type('NONE'); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
around visit_hash => sub { |
51
|
|
|
|
|
|
|
my ( $orig, $self, $hash ) = @_; |
52
|
|
|
|
|
|
|
$self->dive(); |
53
|
|
|
|
|
|
|
if ( $self->current_template =~ /\/$/ ) { |
54
|
|
|
|
|
|
|
my $temp = $self->current_template; |
55
|
|
|
|
|
|
|
$self->reset_template(); |
56
|
|
|
|
|
|
|
$temp =~ s/\/$//; |
57
|
|
|
|
|
|
|
$self->append_text($temp); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
warn 'HASH: ' . $self->current_template if DEBUG; |
60
|
|
|
|
|
|
|
$self->$orig($hash); |
61
|
|
|
|
|
|
|
$self->rise(); |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
around visit_value => sub { |
65
|
|
|
|
|
|
|
my ( $orig, $self, $val ) = @_; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
if ( $self->value_type eq 'NONE' ) { |
68
|
|
|
|
|
|
|
$self->dive(); |
69
|
|
|
|
|
|
|
$self->append_text( $val . '/*' ); |
70
|
|
|
|
|
|
|
$self->add_template( $self->current_template ); |
71
|
|
|
|
|
|
|
warn 'VALUE: ' . $self->current_template if DEBUG; |
72
|
|
|
|
|
|
|
$self->rise(); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
elsif ( $self->value_type eq 'HashKey' ) { |
75
|
|
|
|
|
|
|
$self->append_text($val); |
76
|
|
|
|
|
|
|
warn 'VALUE: ' . $self->current_template if DEBUG; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
else { |
79
|
|
|
|
|
|
|
$self->$orig($val); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
}; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=pod |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 NAME |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Catalyst::Controller::DBIC::API::Validator::Visitor - Provides validation services for inbound requests against whitelisted parameters |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 VERSION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
version 2.008001 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 PRIVATE_ATTRIBUTES |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 DEBUG |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Debugging warnings can be enabled by setting the environment variable |
105
|
|
|
|
|
|
|
DATA_DPATH_VALIDATOR_DEBUG to a true value. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHORS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=over 4 |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Nicholas Perez <nperez@cpan.org> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Luke Saunders <luke.saunders@gmail.com> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Alexander Hartmaier <abraxxa@cpan.org> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Oleg Kostyuk <cub.uanic@gmail.com> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Samuel Kaufman <sam@socialflow.com> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=back |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This software is copyright (c) 2019 by Luke Saunders, Nicholas Perez, Alexander Hartmaier, et al. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
142
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |