line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Cookies::iCab; |
2
|
3
|
|
|
3
|
|
100511
|
use strict; |
|
3
|
|
|
|
|
23
|
|
|
3
|
|
|
|
|
103
|
|
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
19
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
102
|
|
5
|
3
|
|
|
3
|
|
18
|
no warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
177
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
HTTP::Cookies::iCab - Cookie storage and management for iCab |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use HTTP::Cookies::iCab; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $cookie_jar = HTTP::Cookies::iCab->new( $cookies_file ); |
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 iCab 3 cookie files. This doesn't work on iCab |
23
|
|
|
|
|
|
|
4 cookie files yet, but if you really need that, convert HTTP::Cookies::Safari |
24
|
|
|
|
|
|
|
to do what you need. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
See L. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SOURCE AVAILABILITY |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This is an abandoned module. The source might still be at: |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
https://github.com/CPAN-Adoptable-Modules/http-cookies-icab |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 AUTHOR |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
brian d foy, C<< >> |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Copyright © 2003-2018, brian d foy . All rights reserved. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
43
|
|
|
|
|
|
|
it under the terms of the Artistic License 2.0. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#/Users/brian/Library/Preferences/iCab Preferences/iCab Cookies |
48
|
|
|
|
|
|
|
# Time::Local::timelocal(0,0,0,1,0,70) |
49
|
|
|
|
|
|
|
|
50
|
3
|
|
|
3
|
|
29
|
use base qw( HTTP::Cookies ); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
1949
|
|
51
|
3
|
|
|
3
|
|
41889
|
use vars qw( $VERSION ); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
143
|
|
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
3
|
|
21
|
use constant TRUE => 'TRUE'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
201
|
|
54
|
3
|
|
|
3
|
|
18
|
use constant FALSE => 'FALSE'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
136
|
|
55
|
3
|
|
|
3
|
|
16
|
use constant OFFSET => 2_082_823_200; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
3506
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$VERSION = '1.132'; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $Debug = $ENV{DEBUG} || 0; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub load |
62
|
|
|
|
|
|
|
{ |
63
|
2
|
|
|
2
|
1
|
646
|
my( $self, $file ) = @_; |
64
|
|
|
|
|
|
|
|
65
|
2
|
|
50
|
|
|
19
|
$file ||= $self->{'file'} || return; |
|
|
|
33
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
2
|
50
|
|
|
|
94
|
open my $fh, '<:raw', $file or die "Could not open file [$file]: $!"; |
68
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
28
|
my $size = -s $file; |
70
|
|
|
|
|
|
|
|
71
|
2
|
|
|
|
|
40
|
COOKIE: until( eof $fh ) |
72
|
|
|
|
|
|
|
{ |
73
|
10
|
50
|
|
|
|
32
|
print STDERR "\n", "-" x 73, "\n" if $Debug; |
74
|
10
|
|
|
|
|
23
|
my $set_date = read_date( $fh ); |
75
|
10
|
50
|
|
|
|
21
|
print STDERR ( "\tset date is " . localtime( $set_date ) . "\n" ) |
76
|
|
|
|
|
|
|
if $Debug; |
77
|
10
|
|
|
|
|
16
|
my $tag = read_str( $fh, 4 ); |
78
|
10
|
50
|
|
|
|
23
|
print STDERR ( "==> tag is [$tag] not 'Cook'\n" ) |
79
|
|
|
|
|
|
|
unless $tag eq 'Cook'; |
80
|
|
|
|
|
|
|
|
81
|
10
|
|
|
|
|
19
|
my $name = read_var( $fh ); |
82
|
10
|
50
|
|
|
|
22
|
warn( "\tname is [$name]\n" ) if $Debug; |
83
|
10
|
|
|
|
|
18
|
my $path = read_var( $fh ); |
84
|
10
|
50
|
|
|
|
24
|
warn( "\tpath is [$path]\n" ) if $Debug; |
85
|
10
|
|
|
|
|
16
|
my $domain = read_var( $fh ); |
86
|
10
|
50
|
|
|
|
21
|
warn( "\tdomain is [$domain]\n" ) if $Debug; |
87
|
10
|
|
|
|
|
15
|
my $value = read_var( $fh ); |
88
|
10
|
50
|
|
|
|
22
|
warn( "\tvalue is [$value]\n" ) if $Debug; |
89
|
|
|
|
|
|
|
|
90
|
10
|
|
|
|
|
15
|
my $expires = read_int( $fh ) - OFFSET; |
91
|
|
|
|
|
|
|
|
92
|
10
|
50
|
|
|
|
22
|
warn( "\t$name expires at " . |
93
|
|
|
|
|
|
|
localtime( $expires ) . "\n" ) if $Debug; |
94
|
10
|
|
|
|
|
15
|
my $str = read_str( $fh, 7 ); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
DATE: { |
97
|
10
|
|
|
|
|
22
|
my $pos = tell $fh; |
|
10
|
|
|
|
|
20
|
|
98
|
10
|
50
|
|
|
|
18
|
warn( "read $pos of $size bytes\n" ) if $Debug > 1; |
99
|
10
|
100
|
|
|
|
34
|
if( eof $fh ) |
100
|
|
|
|
|
|
|
{ |
101
|
2
|
50
|
|
|
|
19
|
warn( "At end of file, setting cookie [$name]\n" ) if $Debug; |
102
|
2
|
|
|
|
|
10
|
$self->set_cookie(undef, $name, $value, $path, |
103
|
|
|
|
|
|
|
$domain, undef, 0, 0, $expires - time, 0); |
104
|
|
|
|
|
|
|
|
105
|
2
|
|
|
|
|
52
|
last COOKIE; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
8
|
|
|
|
|
23
|
my $peek = peek( $fh, 12 ); |
109
|
8
|
50
|
|
|
|
21
|
warn( "\t--peek is $peek\n" ) if $Debug > 1; |
110
|
|
|
|
|
|
|
|
111
|
8
|
50
|
|
|
|
24
|
if( substr( $peek, 8, 4 ) eq 'Cook' ) |
112
|
|
|
|
|
|
|
{ |
113
|
8
|
50
|
|
|
|
33
|
warn( "Setting cookie [$name]\n" ) if $Debug; |
114
|
8
|
|
|
|
|
46
|
$self->set_cookie(undef, $name, $value, $path, |
115
|
|
|
|
|
|
|
$domain, undef, 0, 0, $expires - time, 0); |
116
|
8
|
|
|
|
|
282
|
next COOKIE; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
0
|
my $date = read_date( $fh ); |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
0
|
redo; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
2
|
|
|
|
|
20
|
close $fh; |
127
|
|
|
|
|
|
|
|
128
|
2
|
|
|
|
|
12
|
1; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub save |
132
|
|
|
|
|
|
|
{ |
133
|
1
|
|
|
1
|
1
|
555
|
my( $self, $file ) = @_; |
134
|
|
|
|
|
|
|
|
135
|
1
|
|
0
|
|
|
4
|
$file ||= $self->{'file'} || return; |
|
|
|
33
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
1
|
50
|
|
|
|
103
|
open my $fh, '>:raw', $file or die "Could not write file [$file]! $!\n"; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$self->scan( |
140
|
|
|
|
|
|
|
sub { |
141
|
5
|
|
|
5
|
|
129
|
my( $version, $key, $val, $path, $domain, $port, |
142
|
|
|
|
|
|
|
$path_spec, $secure, $expires, $discard, $rest ) = @_; |
143
|
|
|
|
|
|
|
|
144
|
5
|
50
|
33
|
|
|
30
|
return if $discard && not $self->{ignore_discard}; |
145
|
|
|
|
|
|
|
|
146
|
5
|
50
|
33
|
|
|
38
|
return if defined $expires && time > $expires; |
147
|
|
|
|
|
|
|
|
148
|
5
|
|
|
|
|
7
|
$expires += OFFSET; |
149
|
|
|
|
|
|
|
|
150
|
5
|
50
|
|
|
|
11
|
$secure = $secure ? TRUE : FALSE; |
151
|
|
|
|
|
|
|
|
152
|
5
|
50
|
|
|
|
19
|
my $bool = $domain =~ /^\./ ? TRUE : FALSE; |
153
|
|
|
|
|
|
|
|
154
|
5
|
|
|
|
|
46
|
print $fh 'Date', pack( 'N', time + OFFSET ), |
155
|
|
|
|
|
|
|
'Cook', |
156
|
|
|
|
|
|
|
pack( 'N', length $key ), $key, |
157
|
|
|
|
|
|
|
pack( 'N', length $path ), $path, |
158
|
|
|
|
|
|
|
pack( 'N', length $domain ), $domain, |
159
|
|
|
|
|
|
|
pack( 'N', length $val ), $val, |
160
|
|
|
|
|
|
|
pack( 'N', $expires ); |
161
|
|
|
|
|
|
|
} |
162
|
1
|
|
|
|
|
16
|
); |
163
|
|
|
|
|
|
|
|
164
|
1
|
|
|
|
|
59
|
close $fh; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub read_int |
168
|
|
|
|
|
|
|
{ |
169
|
60
|
|
|
60
|
0
|
80
|
my $fh = shift; |
170
|
|
|
|
|
|
|
|
171
|
60
|
|
|
|
|
96
|
my $result = read_str( $fh, 4 ); |
172
|
|
|
|
|
|
|
|
173
|
60
|
|
|
|
|
116
|
my $number = unpack( "N", $result ); |
174
|
|
|
|
|
|
|
|
175
|
60
|
|
|
|
|
100
|
return $number; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub read_date |
179
|
|
|
|
|
|
|
{ |
180
|
10
|
|
|
10
|
0
|
16
|
my $fh = shift; |
181
|
|
|
|
|
|
|
|
182
|
10
|
|
|
|
|
21
|
my $string = read_str( $fh, 4 ); |
183
|
10
|
50
|
|
|
|
28
|
warn( "\t==tag is [$string] not 'Date'\n" ) unless $string eq 'Date'; |
184
|
|
|
|
|
|
|
|
185
|
10
|
|
|
|
|
21
|
my $date = read_int( $fh ); |
186
|
10
|
50
|
|
|
|
22
|
warn( sprintf "\t==read date %X | %d | %s\n", $date, $date, |
187
|
|
|
|
|
|
|
scalar localtime $date ) if $Debug > 1; |
188
|
|
|
|
|
|
|
|
189
|
10
|
|
|
|
|
17
|
$date -= OFFSET; |
190
|
10
|
50
|
|
|
|
18
|
warn( sprintf "\t==read date %X | %d | %s\n", $date, $date, |
191
|
|
|
|
|
|
|
scalar localtime $date ) if $Debug > 1; |
192
|
|
|
|
|
|
|
|
193
|
10
|
|
|
|
|
18
|
return $date; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub read_var |
197
|
|
|
|
|
|
|
{ |
198
|
40
|
|
|
40
|
0
|
61
|
my $fh = shift; |
199
|
|
|
|
|
|
|
|
200
|
40
|
|
|
|
|
57
|
my $length = read_int( $fh ); |
201
|
40
|
50
|
|
|
|
71
|
warn "length is $length\n" if $Debug > 1; |
202
|
40
|
|
|
|
|
68
|
my $string = read_str( $fh, $length ); |
203
|
|
|
|
|
|
|
|
204
|
40
|
|
|
|
|
69
|
return $string; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub read_str |
208
|
|
|
|
|
|
|
{ |
209
|
130
|
|
|
130
|
0
|
177
|
my $fh = shift; |
210
|
130
|
|
|
|
|
168
|
my $length = shift; |
211
|
|
|
|
|
|
|
|
212
|
130
|
|
|
|
|
233
|
my $result = read( $fh, my $string, $length ); |
213
|
|
|
|
|
|
|
|
214
|
130
|
|
|
|
|
236
|
return $string; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
sub peek |
218
|
|
|
|
|
|
|
{ |
219
|
8
|
|
|
8
|
0
|
12
|
my $fh = shift; |
220
|
8
|
|
|
|
|
11
|
my $length = shift; |
221
|
|
|
|
|
|
|
|
222
|
8
|
|
|
|
|
17
|
my $result = read( $fh, my $string, $length ); |
223
|
|
|
|
|
|
|
|
224
|
8
|
|
|
|
|
92
|
seek $fh, -$length, 1; |
225
|
|
|
|
|
|
|
|
226
|
8
|
|
|
|
|
24
|
return $string; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
1; |