line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Session::Serialize::default; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: default.pm 224 2005-09-09 07:44:04Z markstos $ |
4
|
|
|
|
|
|
|
|
5
|
12
|
|
|
12
|
|
56
|
use strict; |
|
12
|
|
|
|
|
17
|
|
|
12
|
|
|
|
|
424
|
|
6
|
12
|
|
|
12
|
|
186206
|
use Safe; |
|
12
|
|
|
|
|
374465
|
|
|
12
|
|
|
|
|
629
|
|
7
|
12
|
|
|
12
|
|
6527
|
use Data::Dumper; |
|
12
|
|
|
|
|
51959
|
|
|
12
|
|
|
|
|
826
|
|
8
|
12
|
|
|
12
|
|
82
|
use CGI::Session::ErrorHandler; |
|
12
|
|
|
|
|
16
|
|
|
12
|
|
|
|
|
280
|
|
9
|
12
|
|
|
12
|
|
51
|
use Scalar::Util qw(blessed reftype refaddr); |
|
12
|
|
|
|
|
17
|
|
|
12
|
|
|
|
|
598
|
|
10
|
12
|
|
|
12
|
|
56
|
use Carp "croak"; |
|
12
|
|
|
|
|
17
|
|
|
12
|
|
|
|
|
5798
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
@CGI::Session::Serialize::default::ISA = ( "CGI::Session::ErrorHandler" ); |
13
|
|
|
|
|
|
|
$CGI::Session::Serialize::default::VERSION = '1.5'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub freeze { |
17
|
5
|
|
|
5
|
1
|
11
|
my ($class, $data) = @_; |
18
|
|
|
|
|
|
|
|
19
|
5
|
|
|
|
|
53
|
my $d = new Data::Dumper([$data], ["D"]); |
20
|
5
|
|
|
|
|
195
|
$d->Indent( 0 ); |
21
|
5
|
|
|
|
|
92
|
$d->Purity( 0 ); |
22
|
5
|
|
|
|
|
35
|
$d->Useqq( 0 ); |
23
|
5
|
|
|
|
|
34
|
$d->Deepcopy( 1 ); |
24
|
5
|
|
|
|
|
36
|
$d->Quotekeys( 0 ); |
25
|
5
|
|
|
|
|
32
|
$d->Terse( 0 ); |
26
|
5
|
|
|
|
|
36
|
return $d->Dump(); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub thaw { |
30
|
5
|
|
|
5
|
1
|
10
|
my ($class, $string) = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# To make -T happy |
33
|
5
|
|
|
|
|
34
|
my ($safe_string) = $string =~ m/^(.*)$/s; |
34
|
5
|
|
|
|
|
43
|
my $rv = Safe->new->reval( $safe_string ); |
35
|
5
|
50
|
|
|
|
8164
|
if ( my $errmsg = $@ ) { |
36
|
0
|
|
|
|
|
0
|
return $class->set_error("thaw(): couldn't thaw. $@"); |
37
|
|
|
|
|
|
|
} |
38
|
5
|
|
|
|
|
429
|
__walk($rv); |
39
|
5
|
|
|
|
|
19
|
return $rv; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub __walk { |
43
|
5
|
|
|
5
|
|
8
|
my %seen; |
44
|
5
|
|
|
|
|
13
|
my @filter = shift; |
45
|
|
|
|
|
|
|
|
46
|
5
|
|
|
|
|
23
|
while (defined(my $x = shift @filter)) { |
47
|
0
|
0
|
0
|
|
|
|
$seen{refaddr $x || ''}++ and next; |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
my $r = reftype $x or next; |
50
|
0
|
0
|
0
|
|
|
|
if ($r eq "HASH") { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
push @filter, __scan(@{$x}{keys %$x}); |
|
0
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} elsif ($r eq "ARRAY") { |
53
|
0
|
|
|
|
|
|
push @filter, __scan(@$x); |
54
|
|
|
|
|
|
|
} elsif ($r eq "SCALAR" || $r eq "REF") { |
55
|
0
|
|
|
|
|
|
push @filter, __scan($$x); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub __scan { |
61
|
0
|
|
|
0
|
|
|
for (@_) { |
62
|
0
|
0
|
|
|
|
|
if (blessed $_) { |
63
|
0
|
0
|
|
|
|
|
if (overload::Overloaded($_)) { |
64
|
0
|
|
|
|
|
|
my $r = reftype $_; |
65
|
0
|
0
|
0
|
|
|
|
if ($r eq "HASH") { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$_ = bless { %$_ }, ref $_; |
67
|
|
|
|
|
|
|
} elsif ($r eq "ARRAY") { |
68
|
0
|
|
|
|
|
|
$_ = bless [ @$_ ], ref $_; |
69
|
|
|
|
|
|
|
} elsif ($r eq "SCALAR" || $r eq "REF") { |
70
|
0
|
|
|
|
|
|
$_ = bless \do{my $o = $$_},ref $_; |
|
0
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} else { |
72
|
0
|
|
|
|
|
|
croak "Do not know how to reconstitute blessed object of base type $r"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} else { |
75
|
0
|
|
|
|
|
|
bless $_, ref $_; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
0
|
|
|
|
|
|
return @_; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__; |