line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Cookies::Omniweb; |
2
|
3
|
|
|
3
|
|
164995
|
use strict; |
|
3
|
|
|
|
|
28
|
|
|
3
|
|
|
|
|
105
|
|
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
19
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
92
|
|
5
|
3
|
|
|
3
|
|
15
|
no warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
142
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=encoding utf8 |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
HTTP::Cookies::Omniweb - Cookie storage and management for Omniweb |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use HTTP::Cookies::Omniweb; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$cookie_jar = HTTP::Cookies::Omniweb->new; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# otherwise same as HTTP::Cookies |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This package overrides the C and C methods of HTTP::Cookies |
24
|
|
|
|
|
|
|
so it can work with Omniweb cookie files. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
See L. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 BUGS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Although Omniweb declares that it uses a DTD, the URL to the DTD is |
31
|
|
|
|
|
|
|
dead. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Omniweb seems to not store the path for cookies unless it is not |
34
|
|
|
|
|
|
|
/, and sometimes it stores it as %2f. I haven't completely figured |
35
|
|
|
|
|
|
|
that out, so output files will not exactly match input files. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SOURCE AVAILABILITY |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
This code is in Github: |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
https://github.com/CPAN-Adoptable-Modules/HTTP-Cookies-Omniweb |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 AUTHOR |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
brian d foy, C<< >> |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Copyright © 2002-2018, brian d foy . All rights reserved. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
52
|
|
|
|
|
|
|
it under the terms of the Artistic License 2.0. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
3
|
|
|
3
|
|
19
|
use base qw( HTTP::Cookies ); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
1891
|
|
57
|
3
|
|
|
3
|
|
42885
|
use vars qw( $VERSION ); |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
178
|
|
58
|
|
|
|
|
|
|
|
59
|
3
|
|
|
3
|
|
30
|
use constant TRUE => 'TRUE'; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
266
|
|
60
|
3
|
|
|
3
|
|
27
|
use constant FALSE => 'FALSE'; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
2958
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$VERSION = '1.131'; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $EPOCH_OFFSET = 978_350_400; # difference from Unix epoch |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub load |
67
|
|
|
|
|
|
|
{ |
68
|
2
|
|
|
2
|
1
|
240
|
my( $self, $file ) = @_; |
69
|
|
|
|
|
|
|
|
70
|
2
|
|
50
|
|
|
21
|
$file ||= $self->{'file'} || return; |
|
|
|
33
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
2
|
|
|
|
|
3
|
local $_; |
73
|
2
|
|
|
|
|
11
|
local $/ = "\n"; # make sure we got standard record separator |
74
|
|
|
|
|
|
|
|
75
|
2
|
50
|
|
|
|
97
|
open my $fh, $file or return; |
76
|
|
|
|
|
|
|
|
77
|
2
|
|
|
|
|
71
|
my $magic = ( <$fh>, <$fh>, <$fh> ); |
78
|
|
|
|
|
|
|
|
79
|
2
|
50
|
|
|
|
31
|
unless( $magic =~ /^\s*\s*$/ ) |
80
|
|
|
|
|
|
|
{ |
81
|
0
|
0
|
|
|
|
0
|
warn "$file does not look like an Omniweb cookies file" if $^W; |
82
|
0
|
|
|
|
|
0
|
close $fh; |
83
|
0
|
|
|
|
|
0
|
return; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
2
|
|
|
|
|
10
|
my $now = time() - $EPOCH_OFFSET; |
87
|
|
|
|
|
|
|
|
88
|
2
|
|
|
|
|
6
|
my $domain; |
89
|
2
|
|
|
|
|
16
|
while( <$fh> ) |
90
|
|
|
|
|
|
|
{ |
91
|
18
|
100
|
|
|
|
329
|
$domain = $1 if m//; |
92
|
18
|
100
|
|
|
|
56
|
next if m||; |
93
|
14
|
100
|
|
|
|
56
|
last if m||; |
94
|
12
|
100
|
|
|
|
58
|
next unless m|
|
95
|
|
|
|
|
|
|
|
96
|
8
|
50
|
|
|
|
29
|
my $path = m/path="(.*?)"/ ? $1 : "/"; |
97
|
8
|
|
|
|
|
17
|
$path =~ s|%2f|/|ig; |
98
|
|
|
|
|
|
|
|
99
|
8
|
50
|
|
|
|
42
|
my $name = $1 if m/name="(.*?)"/; |
100
|
8
|
50
|
|
|
|
38
|
my $value = $1 if m/value="(.*?)"/; |
101
|
8
|
50
|
|
|
|
32
|
my $expires = $1 if m/expires="(.*?)"/; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
#print STDERR "D=$domain P=$path N=$name V=$value E=$expires\n"; |
104
|
|
|
|
|
|
|
|
105
|
8
|
|
|
|
|
15
|
my $secure = FALSE; |
106
|
|
|
|
|
|
|
|
107
|
8
|
|
|
|
|
51
|
$self->set_cookie(undef, $name, $value, $path, $domain, undef, |
108
|
|
|
|
|
|
|
0, $secure, $expires - $now, 0); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
2
|
|
|
|
|
37
|
close $fh; |
112
|
|
|
|
|
|
|
|
113
|
2
|
|
|
|
|
19
|
1; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub save |
117
|
|
|
|
|
|
|
{ |
118
|
1
|
|
|
1
|
1
|
551
|
my( $self, $file ) = @_; |
119
|
|
|
|
|
|
|
|
120
|
1
|
|
0
|
|
|
4
|
$file ||= $self->{'file'} || return; |
|
|
|
33
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
1
|
|
|
|
|
2
|
local $_; |
123
|
1
|
50
|
|
1
|
|
40
|
open my $fh, '>:encoding(UTF-8)', $file or return; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
124
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
12981
|
print $fh <<'EOT'; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
EOT |
130
|
|
|
|
|
|
|
|
131
|
1
|
|
|
|
|
3
|
my $now = time - $EPOCH_OFFSET; |
132
|
|
|
|
|
|
|
|
133
|
1
|
|
|
|
|
2
|
foreach my $domain ( sort keys %{ $self->{COOKIES} } ) |
|
1
|
|
|
|
|
14
|
|
134
|
|
|
|
|
|
|
{ |
135
|
2
|
|
|
|
|
8
|
my $domain_hash = $self->{COOKIES}{$domain}; |
136
|
|
|
|
|
|
|
|
137
|
2
|
|
|
|
|
7
|
print $fh qq|\n|; |
138
|
|
|
|
|
|
|
|
139
|
2
|
|
|
|
|
8
|
PATH: foreach my $path ( sort keys %$domain_hash ) |
140
|
|
|
|
|
|
|
{ |
141
|
2
|
|
|
|
|
4
|
my $cookie_hash = $domain_hash->{ $path }; |
142
|
|
|
|
|
|
|
|
143
|
2
|
|
|
|
|
7
|
COOKIE: foreach my $name ( sort keys %$cookie_hash ) |
144
|
|
|
|
|
|
|
{ |
145
|
4
|
|
|
|
|
10
|
my( $value, $expires ) = @{ $cookie_hash->{$name} }[ 1, 5 ]; |
|
4
|
|
|
|
|
14
|
|
146
|
4
|
|
|
|
|
11
|
$expires -= $EPOCH_OFFSET; |
147
|
4
|
50
|
|
|
|
11
|
my $path_str = $path eq '/' ? '' : qq| path="$path"|; |
148
|
|
|
|
|
|
|
|
149
|
4
|
|
|
|
|
28
|
print $fh qq|
|
150
|
|
|
|
|
|
|
qq| expires="$expires" />\n|; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
2
|
|
|
|
|
9
|
print $fh "\n"; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
1
|
|
|
|
|
3
|
print $fh "\n"; |
158
|
|
|
|
|
|
|
|
159
|
1
|
|
|
|
|
59
|
close $fh; |
160
|
|
|
|
|
|
|
|
161
|
1
|
|
|
|
|
10
|
1; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |