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