| 1 | package CGI::Untaint::url; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | $VERSION = '1.00'; | |||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use base 'CGI::Untaint::printable'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use URI::Find::Schemeless::Stricter; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 0 | ▶ | sub is_valid { | ||||||||
|
Subroutine
is_valid: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 10 | 0 | my $self = shift; | |||||||||
| 11 | 0 | ▶ | my $value = $self->value or die "No value\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | 0 | my @urls; | |||||||||
| 13 | our $finder = URI::Find::Schemeless::Stricter->new( | ||||||||||
| 14 | 0 | ▶ | sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 15 | 0 | push @urls, shift; | |||||||||
| 16 | } | ||||||||||
| 17 | 0 | ); | |||||||||
| 18 | 0 | $finder->find(\$value); | |||||||||
| 19 | 0 | ▶ | return $self->value($urls[0]) if @urls; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 0 | 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<URI::URL> object. | ||||||||||
| 51 | |||||||||||
| 52 | =head1 SEE ALSO | ||||||||||
| 53 | |||||||||||
| 54 | L<URI::URL>. L<URI::Find::Schemeless::Stricter>. | ||||||||||
| 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 | 1; | |||||||||