| 1 | package HTTP::Cookies::Wget; | ||||||||||||||||||||||||||||
| 2 | 25 | $HTTP::Cookies::Wget::VERSION = '0.2602'; | |||||||||||||||||||||||||||
| 3 | 25 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 25 | our @ISA=qw(HTTP::Cookies); | |||||||||||||||||||||||||||
| 6 | 25 | require HTTP::Cookies; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | sub load | ||||||||||||||||||||||||||||
| 9 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
load: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 10 | 0 | my($self, $file) = @_; | |||||||||||||||||||||||||||
| 11 | 0 | ▶ | $file ||= $self->{'file'} || return; | ||||||||||||||||||||||||||
|
Condition0%0/5
$file ||= $self->{"file"} || (return)
$self->{'file'} || (return)
MC/DC0%0/2
$file ||= $self->{"file"} || (return)
$file
$self->{'file'}
Truth table0%0/3
A ||= B
A= $fileB= $self->{'file'}
| |||||||||||||||||||||||||||||
| 12 | 0 | local(*FILE, $_); | |||||||||||||||||||||||||||
| 13 | 0 | local $/ = "\n"; # make sure we got standard record separator | |||||||||||||||||||||||||||
| 14 | 0 | my @cookies; | |||||||||||||||||||||||||||
| 15 | 0 | ▶ | open(FILE, $file) || return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # don't check for a header; not all export programs save one | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 0 | my $now = time() - $HTTP::Cookies::EPOCH_OFFSET; | |||||||||||||||||||||||||||
| 20 | 0 | ▶ | while (<FILE>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | next if /^\s*\#/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | next if /^\s*$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 0 | tr/\n\r//d; | |||||||||||||||||||||||||||
| 24 | 0 | my($domain,$bool1,$path,$secure, $expires,$key,$val) = split(/\t/, $_); | |||||||||||||||||||||||||||
| 25 | 0 | $secure = ($secure eq "TRUE"); | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # Give expired cookies a fake maxage, because we want all cookies | ||||||||||||||||||||||||||||
| 28 | # including session cookies | ||||||||||||||||||||||||||||
| 29 | 0 | my $maxage = $expires-$now; | |||||||||||||||||||||||||||
| 30 | 0 | ▶ | if ($maxage < 0) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | { | ||||||||||||||||||||||||||||
| 32 | 0 | $maxage = 9999999; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | # Tweak the domain for livejournal cookies, | ||||||||||||||||||||||||||||
| 35 | # because it puts '.' in front of all of them | ||||||||||||||||||||||||||||
| 36 | # whether they need it or not, and this apparently confuses LWP | ||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if ($domain =~ /^\.([-\w]+\.livejournal\.com)$/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | { | ||||||||||||||||||||||||||||
| 39 | 0 | $domain = $1; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | $self->set_cookie(undef,$key,$val,$path,$domain,undef, | |||||||||||||||||||||||||||
| 43 | 0,$secure,$maxage, 0); | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | 0 | close(FILE); | |||||||||||||||||||||||||||
| 46 | 0 | 1; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | sub save | ||||||||||||||||||||||||||||
| 50 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
save: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 51 | 0 | my($self, $file) = @_; | |||||||||||||||||||||||||||
| 52 | 0 | ▶ | $file ||= $self->{'file'} || return; | ||||||||||||||||||||||||||
|
Condition0%0/5
$file ||= $self->{"file"} || (return)
$self->{'file'} || (return)
MC/DC0%0/2
$file ||= $self->{"file"} || (return)
$file
$self->{'file'}
Truth table0%0/3
A ||= B
A= $fileB= $self->{'file'}
| |||||||||||||||||||||||||||||
| 53 | 0 | local(*FILE, $_); | |||||||||||||||||||||||||||
| 54 | 0 | ▶ | open(FILE, ">$file") || return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | # Use old, now broken link to the old cookie spec just in case something | ||||||||||||||||||||||||||||
| 57 | # else (not us!) requires the comment block exactly this way. | ||||||||||||||||||||||||||||
| 58 | 0 | print FILE <<EOT; | |||||||||||||||||||||||||||
| 59 | # Wget HTTP Cookie File | ||||||||||||||||||||||||||||
| 60 | # http://www.netscape.com/newsref/std/cookie_spec.html | ||||||||||||||||||||||||||||
| 61 | # This is a generated file! Do not edit. | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | EOT | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | my $now = time - $HTTP::Cookies::EPOCH_OFFSET; | |||||||||||||||||||||||||||
| 66 | 0 | ▶ | $self->scan(sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 67 | 0 | my($version,$key,$val,$path,$domain,$port, | |||||||||||||||||||||||||||
| 68 | $path_spec,$secure,$expires,$discard,$rest) = @_; | ||||||||||||||||||||||||||||
| 69 | 0 | ▶ | return if $discard && !$self->{ignore_discard}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$discard and not $self->{"ignore_discard"}
MC/DC0%0/2
$discard and not $self->{"ignore_discard"}
$discard
not $self->{"ignore_discard"}
Truth table0%0/3
A and not(B)
A= $discardB= not $self->{"ignore_discard"}
| |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | $expires = $expires ? $expires - $HTTP::Cookies::EPOCH_OFFSET : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | return if $now > $expires; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $secure = $secure ? "TRUE" : "FALSE"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | my $bool = $domain =~ /^\./ ? "TRUE" : "FALSE"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 0 | print FILE join("\t", $domain, $bool, $path, $secure, $expires, $key, $val), "\n"; | |||||||||||||||||||||||||||
| 75 | 0 | }); | |||||||||||||||||||||||||||
| 76 | 0 | close(FILE); | |||||||||||||||||||||||||||
| 77 | 0 | 1; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 25 | 1; | |||||||||||||||||||||||||||
| 81 | __END__ | ||||||||||||||||||||||||||||