| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CGI::Untaint::url; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '1.00'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6730
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
33
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use base 'CGI::Untaint::printable'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
821
|
|
|
7
|
1
|
|
|
1
|
|
1471
|
use URI::Find::Schemeless::Stricter; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub is_valid { |
|
10
|
|
|
|
|
|
|
my $self = shift; |
|
11
|
|
|
|
|
|
|
my $value = $self->value or die "No value\n"; |
|
12
|
|
|
|
|
|
|
my @urls; |
|
13
|
|
|
|
|
|
|
our $finder = URI::Find::Schemeless::Stricter->new( |
|
14
|
|
|
|
|
|
|
sub { |
|
15
|
|
|
|
|
|
|
push @urls, shift; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
$finder->find(\$value); |
|
19
|
|
|
|
|
|
|
return $self->value($urls[0]) if @urls; |
|
20
|
|
|
|
|
|
|
return; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
CGI::Untaint::url - validate a URL |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use CGI::Untaint; |
|
30
|
|
|
|
|
|
|
my $handler = CGI::Untaint->new($q->Vars); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $url = $handler->extract(-as_url => 'web_address'); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 is_valid |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
This Input Handler verifies that it is dealing with a reasonable |
|
39
|
|
|
|
|
|
|
URL. This mostly means that it will find the first thing that looks |
|
40
|
|
|
|
|
|
|
like a URL in your input, where by "looks like", we mean anything that |
|
41
|
|
|
|
|
|
|
URI::URL thinks is sensible, (with some tweaks, courtesy of |
|
42
|
|
|
|
|
|
|
URI::Find::Schemeless::Stricter), so it will accept any of (for example): |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
http://c2.com/cgi/wiki |
|
45
|
|
|
|
|
|
|
www.tmtm.com |
|
46
|
|
|
|
|
|
|
See: http://www.redmeat.com/redmeat/1996-09-30/ |
|
47
|
|
|
|
|
|
|
[http://www.angelfire.com/la/carlosmay/Tof.html] |
|
48
|
|
|
|
|
|
|
ftp://ftp.ftp.org/ |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
The resulting value will be a L object. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
L. L. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 AUTHOR |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Tony Bowden |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 BUGS and QUERIES |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Please direct all correspondence regarding this module to: |
|
63
|
|
|
|
|
|
|
bug-CGI-Untaint-url@rt.cpan.org |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Copyright (C) 2001-2005 Tony Bowden. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
|
70
|
|
|
|
|
|
|
the terms of the GNU General Public License; either version 2 of the License, |
|
71
|
|
|
|
|
|
|
or (at your option) any later version. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT |
|
74
|
|
|
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
75
|
|
|
|
|
|
|
FOR A PARTICULAR PURPOSE. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |