line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
17
|
|
|
17
|
|
112
|
use strict; |
|
17
|
|
|
|
|
32
|
|
|
17
|
|
|
|
|
961
|
|
2
|
17
|
|
|
17
|
|
145
|
use warnings FATAL => 'all'; |
|
17
|
|
|
|
|
34
|
|
|
17
|
|
|
|
|
1032
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package HTML::Tested::Test::Value; |
5
|
17
|
|
|
17
|
|
107
|
use HTML::Tested::Test qw(Ensure_Value_To_Check Stash_Mismatch); |
|
17
|
|
|
|
|
32
|
|
|
17
|
|
|
|
|
36138
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub _replace_sealed { |
8
|
62
|
|
|
62
|
|
132
|
my ($class, $val) = @_; |
9
|
62
|
|
|
|
|
424
|
my $s = HTML::Tested::Seal->instance; |
10
|
62
|
|
100
|
|
|
1551
|
$val =~ s#([0-9a-f]{16}[0-9a-f]*)#$s->decrypt($1) // 'ENCRYPTED'#eg; |
|
73
|
|
|
|
|
335
|
|
11
|
62
|
|
|
|
|
346
|
return $val; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head2 $class->is_marked_as_sealed($e_root, $name) |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Checks whether variable C<$name> was marked as HT_SEALED. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
sub is_marked_as_sealed { |
20
|
84
|
|
|
84
|
1
|
167
|
my ($class, $e_root, $name) = @_; |
21
|
84
|
|
|
|
|
724
|
return $e_root->{"__HT_SEALED__$name"}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 $class->handle_sealed($e_root, $name, $e_val, $r_val, $err) |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Is called to handle sealed value if needed. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
sub handle_sealed { |
30
|
85
|
|
|
85
|
1
|
217
|
my ($class, $e_root, $name, $e_val, $r_val, $err) = @_; |
31
|
85
|
100
|
|
|
|
283
|
if ($class->is_marked_as_sealed($e_root, $name)) { |
|
|
100
|
|
|
|
|
|
32
|
31
|
|
|
|
|
60
|
my $orig_r_val = $r_val; |
33
|
31
|
|
|
|
|
302
|
$e_val = $class->_replace_sealed($e_val); |
34
|
31
|
|
|
|
|
184
|
$r_val = $class->_replace_sealed($r_val); |
35
|
31
|
100
|
100
|
|
|
211
|
push @$err, "$name wasn't sealed $r_val" |
36
|
|
|
|
|
|
|
if (($orig_r_val eq $r_val) |
37
|
|
|
|
|
|
|
&& !$e_root->{"__HT_REVERTED__$name"}); |
38
|
|
|
|
|
|
|
} elsif ($e_root->ht_get_widget_option($name, "is_sealed")) { |
39
|
2
|
|
|
|
|
8
|
push @$err, "HT_SEALED was not defined on $name"; |
40
|
|
|
|
|
|
|
} |
41
|
85
|
|
|
|
|
521
|
return ($e_val, $r_val); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _is_equal { |
45
|
83
|
|
|
83
|
|
172
|
my ($class, $e_val, $cb) = @_; |
46
|
83
|
100
|
|
|
|
211
|
return 1 if $cb->($e_val); |
47
|
22
|
50
|
|
|
|
152
|
return undef unless ($e_val =~ /(\$VAR1 = \[.*\];)/ms); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
my $arr_str = $1; |
50
|
0
|
|
|
|
|
0
|
my $VAR1; |
51
|
0
|
|
|
|
|
0
|
eval $arr_str; |
52
|
0
|
0
|
|
|
|
0
|
die $@ if $@; |
53
|
0
|
|
|
|
|
0
|
for (@$VAR1) { |
54
|
0
|
|
|
|
|
0
|
my $ev = $e_val; |
55
|
0
|
|
|
|
|
0
|
$ev =~ s#\$VAR1 = \[.*\];\n#$_#ms; |
56
|
0
|
0
|
|
|
|
0
|
return 1 if $cb->($ev); |
57
|
|
|
|
|
|
|
} |
58
|
0
|
|
|
|
|
0
|
return undef; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub check_stash { |
62
|
53
|
|
|
53
|
0
|
129
|
my ($class, $e_root, $name, $e_stash, $r_stash) = @_; |
63
|
53
|
|
|
|
|
91
|
my @err; |
64
|
53
|
100
|
|
|
|
186
|
goto OUT unless exists($e_stash->{$name}); |
65
|
|
|
|
|
|
|
|
66
|
51
|
|
|
|
|
117
|
my $e_val = $e_stash->{$name}; |
67
|
51
|
|
|
|
|
315
|
my $r_val = Ensure_Value_To_Check($r_stash, $name, $e_val, \@err); |
68
|
51
|
100
|
|
|
|
490
|
goto OUT unless defined($r_val); |
69
|
|
|
|
|
|
|
|
70
|
49
|
|
|
|
|
237
|
($e_val, $r_val) = $class->handle_sealed($e_root, $name |
71
|
|
|
|
|
|
|
, $e_val, $r_val, \@err); |
72
|
|
|
|
|
|
|
goto OUT if (@err || $class->_is_equal($e_val |
73
|
49
|
100
|
100
|
47
|
|
715
|
, sub { $r_val eq $_[0]; })); |
|
47
|
|
|
|
|
541
|
|
74
|
13
|
|
|
|
|
111
|
@err = Stash_Mismatch($name, $r_val, $e_val); |
75
|
53
|
|
|
|
|
586
|
OUT: |
76
|
|
|
|
|
|
|
return @err; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub bless_from_tree { |
80
|
82
|
|
|
82
|
0
|
146
|
my $class = shift; |
81
|
82
|
|
|
|
|
422
|
return shift()->bless_from_tree(@_); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _check_text_i { |
85
|
37
|
|
|
37
|
|
82
|
my ($class, $e_root, $name, $v, $text) = @_; |
86
|
37
|
100
|
|
|
|
101
|
return () unless defined($v); |
87
|
36
|
|
|
|
|
43
|
my @ret; |
88
|
36
|
|
|
|
|
142
|
($v, $text) = $class->handle_sealed($e_root, $name, $v, $text, \@ret); |
89
|
|
|
|
|
|
|
|
90
|
36
|
|
|
36
|
|
326
|
my $ok = $class->_is_equal($v, sub { index($text, $_[0]) != -1; }); |
|
36
|
|
|
|
|
267
|
|
91
|
36
|
100
|
100
|
|
|
358
|
return ("Unexpectedly found \"$v\" in \"$text\"") |
92
|
|
|
|
|
|
|
if ($ok && $e_root->{"__HT_REVERTED__$name"}); |
93
|
34
|
100
|
66
|
|
|
230
|
return ("Unable to find \"$v\" in \"$text\"") |
94
|
|
|
|
|
|
|
if (!$ok && !$e_root->{"__HT_REVERTED__$name"}); |
95
|
27
|
|
|
|
|
169
|
return (); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub check_text { |
99
|
22
|
|
|
22
|
0
|
53
|
my ($class, $e_root, $name, $e_stash, $text) = @_; |
100
|
22
|
|
|
|
|
133
|
return $class->_check_text_i($e_root, $name, |
101
|
|
|
|
|
|
|
, $e_stash->{$name}, $text); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub convert_to_param { |
105
|
13
|
|
|
13
|
0
|
155
|
my ($class, $obj_class, $r, $name, $val) = @_; |
106
|
13
|
|
|
|
|
60
|
$r->param($name, $val); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub convert_to_sealed { |
110
|
1
|
|
|
1
|
0
|
3
|
my ($class, $val) = @_; |
111
|
1
|
|
|
|
|
32
|
return HTML::Tested::Seal->instance->encrypt($val); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |