line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenID::Lite::Identifier; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
632
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
68
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
107
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use overload |
7
|
0
|
|
|
0
|
|
0
|
q{""} => sub { shift->as_string }, |
8
|
2
|
|
|
2
|
|
11
|
fallback => 1; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
20
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
1173
|
use URI; |
|
2
|
|
|
|
|
4964
|
|
|
2
|
|
|
|
|
51
|
|
11
|
2
|
|
|
2
|
|
1219
|
use OpenID::Lite::Util::URI; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
1055
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
10
|
|
|
10
|
0
|
15
|
my $class = shift; |
15
|
10
|
|
|
|
|
62
|
bless { |
16
|
|
|
|
|
|
|
is_xri => 0, |
17
|
|
|
|
|
|
|
raw => '', |
18
|
|
|
|
|
|
|
}, $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub normalize { |
22
|
10
|
|
|
10
|
0
|
7255
|
my ( $class, $uri ) = @_; |
23
|
10
|
|
|
|
|
37
|
my $self = $class->new; |
24
|
10
|
50
|
|
|
|
60
|
if ( $uri =~ /^xri:\/\/([\=\@\+\$\!\)].+)$/ ) { |
|
|
50
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
$self->{is_xri} = 1; |
26
|
0
|
|
|
|
|
0
|
$self->{raw} = $1; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
elsif ( $uri =~ /^[\=\@\+\$\!\)]/ ) { |
29
|
0
|
|
|
|
|
0
|
$self->{is_xri} = 1; |
30
|
0
|
|
|
|
|
0
|
$self->{raw} = $uri; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else { |
33
|
10
|
|
|
|
|
56
|
$self->{is_xri} = 0; |
34
|
10
|
50
|
|
|
|
53
|
unless ( $uri =~ /^https?:\/\// ) { |
35
|
0
|
|
|
|
|
0
|
$uri = sprintf q{http://%s}, $uri; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# remove fragment |
39
|
10
|
|
|
|
|
27
|
$uri =~ s/\#.*$//; |
40
|
|
|
|
|
|
|
|
41
|
10
|
|
|
|
|
57
|
$uri = OpenID::Lite::Util::URI->normalize($uri); |
42
|
10
|
50
|
|
|
|
44
|
return unless OpenID::Lite::Util::URI->is_uri($uri); |
43
|
10
|
|
|
|
|
40
|
my $u = URI->new($uri)->canonical; |
44
|
|
|
|
|
|
|
=pod |
45
|
|
|
|
|
|
|
my $path = $u->path || '/'; |
46
|
|
|
|
|
|
|
$self->{raw} |
47
|
|
|
|
|
|
|
= ( $u->port == 80 || $u->port == 443 ) |
48
|
|
|
|
|
|
|
? sprintf( q{%s://%s%s}, $u->scheme, $u->host, $path ) |
49
|
|
|
|
|
|
|
: sprintf( q{%s://%s:%d%s}, $u->scheme, $u->host, $u->port, |
50
|
|
|
|
|
|
|
$path ); |
51
|
|
|
|
|
|
|
=cut |
52
|
10
|
|
50
|
|
|
1064
|
$u->path( $u->path || '/' ); |
53
|
10
|
50
|
33
|
|
|
270
|
$u->port( undef ) if $u->port == 80 || $u->port == 443; |
54
|
10
|
|
|
|
|
1133
|
$u->fragment( undef ); |
55
|
10
|
|
|
|
|
93
|
$self->{raw} = $u->as_string; |
56
|
|
|
|
|
|
|
} |
57
|
10
|
|
|
|
|
98
|
return $self; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
0
|
0
|
0
|
sub is_xri { shift->{is_xri} } |
61
|
0
|
|
|
0
|
0
|
0
|
sub is_http_uri { !shift->is_xri } |
62
|
10
|
|
|
10
|
0
|
50
|
sub as_string { shift->{raw} } |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |