line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package URI::Unredirect; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
67166
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
80
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
53
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
921
|
use URI (); |
|
2
|
|
|
|
|
16327
|
|
|
2
|
|
|
|
|
49
|
|
7
|
2
|
|
|
2
|
|
20
|
use URI::Escape (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
534
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub URI::unredirect { |
13
|
4
|
|
|
4
|
0
|
26339
|
my ($uri) = @_; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
|
|
22
|
my $str = $uri->as_string; |
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
|
|
308
|
my $http_idx = rindex $str, 'http'; |
18
|
4
|
100
|
|
|
|
16
|
return $uri unless $http_idx > 0; |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
6
|
$str = substr $str, $http_idx; |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
|
|
4
|
my $amp_idx = index $str, '&'; |
23
|
2
|
50
|
|
|
|
7
|
if ($amp_idx > 0) { |
24
|
0
|
|
|
|
|
0
|
$str = substr $str, 0, $amp_idx; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
9
|
$str = URI::Escape::uri_unescape($str); |
28
|
|
|
|
|
|
|
|
29
|
2
|
50
|
|
|
|
115
|
if ($str =~ m{( https?://\S* [^.,;'">\s\)\]] )}x) { |
30
|
2
|
|
|
|
|
8
|
return URI->new($1); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return $uri; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |