line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Apache::Sling::URL; |
4
|
|
|
|
|
|
|
|
5
|
17
|
|
|
17
|
|
30406
|
use 5.008001; |
|
17
|
|
|
|
|
58
|
|
|
17
|
|
|
|
|
1168
|
|
6
|
17
|
|
|
17
|
|
99
|
use strict; |
|
17
|
|
|
|
|
31
|
|
|
17
|
|
|
|
|
771
|
|
7
|
17
|
|
|
17
|
|
114
|
use warnings; |
|
17
|
|
|
|
|
33
|
|
|
17
|
|
|
|
|
781
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
|
11
|
17
|
|
|
17
|
|
81
|
use base qw(Exporter); |
|
17
|
|
|
|
|
53
|
|
|
17
|
|
|
|
|
11406
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = (); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.27'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#{{{sub add_leading_slash |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub add_leading_slash { |
20
|
3
|
|
|
3
|
1
|
9
|
my ($value) = @_; |
21
|
3
|
100
|
|
|
|
9
|
if ( defined $value ) { |
22
|
2
|
100
|
|
|
|
8
|
if ( $value !~ /^\//msx ) { |
23
|
1
|
|
|
|
|
3
|
$value = "/$value"; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
3
|
|
|
|
|
12
|
return ($value); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#}}} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#{{{sub strip_leading_slash |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub strip_leading_slash { |
34
|
8
|
|
|
8
|
1
|
15
|
my ($value) = @_; |
35
|
8
|
100
|
|
|
|
27
|
if ( defined $value ) { |
36
|
2
|
|
|
|
|
7
|
$value =~ s/^\///msx; |
37
|
|
|
|
|
|
|
} |
38
|
8
|
|
|
|
|
26
|
return ($value); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#}}} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#{{{sub properties_array_to_string |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub properties_array_to_string { |
46
|
12
|
|
|
12
|
1
|
20
|
my ($properties) = @_; |
47
|
12
|
|
|
|
|
15
|
my $property_post_vars; |
48
|
12
|
|
|
|
|
15
|
foreach my $property ( @{$properties} ) { |
|
12
|
|
|
|
|
26
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Escaping single quotes: |
51
|
16
|
|
|
|
|
26
|
$property =~ s/'/\\'/gmsx; |
52
|
16
|
|
|
|
|
41
|
$property =~ /^([^=]*)=(.*)/msx; |
53
|
16
|
100
|
|
|
|
55
|
if ( defined $1 ) { |
54
|
8
|
|
|
|
|
39
|
$property_post_vars .= "'$1','$2',"; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
12
|
100
|
|
|
|
34
|
if ( defined $property_post_vars ) { |
58
|
7
|
|
|
|
|
46
|
$property_post_vars =~ s/,$//msx; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
else { |
61
|
5
|
|
|
|
|
10
|
$property_post_vars = q{}; |
62
|
|
|
|
|
|
|
} |
63
|
12
|
|
|
|
|
41
|
return $property_post_vars; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#}}} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
#{{{sub urlencode |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub urlencode { |
71
|
1
|
|
|
1
|
1
|
2
|
my ($value) = @_; |
72
|
1
|
|
|
|
|
7
|
$value =~ |
73
|
5
|
|
|
|
|
35
|
s/([^a-zA-Z_0-9 ])/"%" . uc(sprintf "%lx" , unpack("C", $1))/egmsx; |
74
|
1
|
|
|
|
|
3
|
$value =~ tr/ /+/; |
75
|
1
|
|
|
|
|
5
|
return ($value); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#}}} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
#{{{sub url_input_sanitize |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub url_input_sanitize { |
83
|
18
|
|
|
18
|
1
|
40
|
my ($url) = @_; |
84
|
18
|
100
|
|
|
|
66
|
$url = ( defined $url ? $url : 'http://localhost:8080' ); |
85
|
18
|
100
|
|
|
|
78
|
$url = ( $url ne q{} ? $url : 'http://localhost:8080' ); |
86
|
18
|
|
|
|
|
57
|
$url =~ s/(.*)\/$/$1/msx; |
87
|
18
|
100
|
|
|
|
103
|
$url = ( $url !~ /^http/msx ? "http://$url" : "$url" ); |
88
|
18
|
|
|
|
|
85
|
return ($url); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#}}} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |