| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MojoX::CPAN::Uploader; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
636918
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
78
|
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
116
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
156
|
|
|
7
|
2
|
|
|
2
|
|
12
|
use File::Basename; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
198
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
943
|
use Mojo::Base '-base'; |
|
|
2
|
|
|
|
|
13913
|
|
|
|
2
|
|
|
|
|
14
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require Mojo::UserAgent; |
|
12
|
|
|
|
|
|
|
require IO::Socket::SSL; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has client => sub { Mojo::UserAgent->new }; |
|
15
|
|
|
|
|
|
|
has [qw/user pass/]; |
|
16
|
|
|
|
|
|
|
has url => sub { Mojo::URL->new('https://pause.perl.org/pause/authenquery') }; |
|
17
|
|
|
|
|
|
|
has defaults => sub { |
|
18
|
|
|
|
|
|
|
{ CAN_MULTIPART => 1, |
|
19
|
|
|
|
|
|
|
SUBMIT_pause99_add_uri_httpupload => |
|
20
|
|
|
|
|
|
|
" Upload this file from my disk ", |
|
21
|
|
|
|
|
|
|
pause99_add_uri_uri => "", |
|
22
|
|
|
|
|
|
|
}; |
|
23
|
|
|
|
|
|
|
}; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $VERSION = '0.032'; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub auth { |
|
28
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
croak("Basic authorization user name can't contain ':'") |
|
31
|
|
|
|
|
|
|
if $_[0] =~ /:/; |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
$self->user(shift); |
|
34
|
0
|
|
|
|
|
|
$self->pass(shift); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub upload { |
|
38
|
0
|
|
|
0
|
1
|
|
my ($self, $file, $subdir) = splice @_, 0, 3; |
|
39
|
0
|
|
|
|
|
|
my $url = $self->url->clone->userinfo($self->user . ':' . $self->pass); |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
croak "Auth info required!" unless $self->user; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $tx = $self->client->post_form( |
|
44
|
|
|
|
|
|
|
$url, |
|
45
|
0
|
0
|
|
|
|
|
{ %{$self->defaults}, |
|
46
|
|
|
|
|
|
|
HIDDENNAME => $self->user, |
|
47
|
|
|
|
|
|
|
pause99_add_uri_upload => basename($file), |
|
48
|
|
|
|
|
|
|
pause99_add_uri_httpupload => {file => $file}, |
|
49
|
|
|
|
|
|
|
($subdir ? (pause99_add_uri_subdirtext => $subdir) : ()), |
|
50
|
|
|
|
|
|
|
}, |
|
51
|
|
|
|
|
|
|
@_ |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
return 1 if $tx->res->code == 200; |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
if ($tx->res->code == 406) { |
|
|
|
0
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $reason = $tx->res->dom->at('blockquote.actionresponse'); |
|
58
|
0
|
|
|
|
|
|
my $title = $reason->at('h3'); |
|
59
|
0
|
0
|
|
|
|
|
$title = $title ? $title->all_text : 'unknown'; |
|
60
|
0
|
|
|
|
|
|
my @p; |
|
61
|
0
|
|
|
|
|
|
my $table = 0; |
|
62
|
|
|
|
|
|
|
$reason->find('p')->each( |
|
63
|
|
|
|
|
|
|
sub { |
|
64
|
0
|
0
|
|
0
|
|
|
return $table = 1 if $_[0]->at('table'); |
|
65
|
0
|
|
|
|
|
|
my $t = shift->all_text; |
|
66
|
0
|
|
|
|
|
|
$t =~ s/^\s+|\s$//g; |
|
67
|
0
|
|
|
|
|
|
$t =~ s/[\n\r]/ /g; |
|
68
|
0
|
|
|
|
|
|
$t =~ s/\s{2,}/ /g; |
|
69
|
0
|
|
|
|
|
|
push @p, $t; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
0
|
|
|
|
|
|
); |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return Mojo::Exception->new( |
|
74
|
|
|
|
|
|
|
"Error '$title' " . $tx->res->code . "\n" . join("\n", @p, '')); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
elsif ($tx->res->code == 401) { |
|
78
|
0
|
|
|
|
|
|
return Mojo::Exception->new( |
|
79
|
|
|
|
|
|
|
"Wrong login/password for Perl Author '" . $self->user . "'"); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return Mojo::Exception->new("Unknown error: " . $tx->res->code); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
|
86
|
|
|
|
|
|
|
__END__ |