line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Apache::Session::Serialize::MongoDB; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
26
|
use 5.010; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
358
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.16'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub serialize { |
9
|
0
|
|
|
0
|
0
|
|
my $session = shift; |
10
|
0
|
|
|
|
|
|
&replaceSpecialCharacters( $session->{data} ); |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub unserialize { |
14
|
0
|
|
|
0
|
0
|
|
my $session = shift; |
15
|
0
|
|
|
|
|
|
&restoreSpecialCharacters( $session->{data} ); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub replaceSpecialCharacters { |
19
|
0
|
|
|
0
|
0
|
|
my $data = shift; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
foreach my $key ( keys %$data ) { |
22
|
0
|
0
|
|
|
|
|
if ( $key =~ /(\.|\$)/ ) { |
23
|
0
|
|
|
|
|
|
my $oldkey = $key; |
24
|
0
|
|
|
|
|
|
$key =~ s:\$:\\u0024:g; |
25
|
0
|
|
|
|
|
|
$key =~ s:\.:\\u002e:g; |
26
|
0
|
|
|
|
|
|
$data->{$key} = $data->{$oldkey}; |
27
|
0
|
|
|
|
|
|
delete $data->{$oldkey}; |
28
|
|
|
|
|
|
|
} |
29
|
0
|
0
|
|
|
|
|
if ( ref( $data->{$key} ) eq 'HASH' ) { |
30
|
0
|
|
|
|
|
|
&replaceSpecialCharacters( $data->{$key} ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub restoreSpecialCharacters { |
36
|
0
|
|
|
0
|
0
|
|
my $data = shift; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
foreach my $key ( keys %$data ) { |
39
|
0
|
0
|
|
|
|
|
if ( $key =~ /(\\u0024|\\u002e)/ ) { |
40
|
0
|
|
|
|
|
|
my $oldkey = $key; |
41
|
0
|
|
|
|
|
|
$key =~ s:\\u0024:\$:g; |
42
|
0
|
|
|
|
|
|
$key =~ s:\\u002e:.:g; |
43
|
0
|
|
|
|
|
|
$data->{$key} = $data->{$oldkey}; |
44
|
0
|
|
|
|
|
|
delete $data->{$oldkey}; |
45
|
|
|
|
|
|
|
} |
46
|
0
|
0
|
|
|
|
|
if ( ref( $data->{$key} ) eq 'HASH' ) { |
47
|
0
|
|
|
|
|
|
&restoreSpecialCharacters( $data->{$key} ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
__END__ |