CGI::Untaint::ipaddress - validate an IP address


CGI-Untaint-ipaddress documentation Contained in the CGI-Untaint-ipaddress distribution.

Index


Code Index:

NAME

Top

CGI::Untaint::ipaddress - validate an IP address

SYNOPSIS

Top

  use CGI::Untaint;
  my $handler = CGI::Untaint->new($q->Vars);

  my $url = $handler->extract( -as_ipaddress => 'ip' );

DESCRIPTION

Top

This CGI::Untaint input handler verifies that it is dealing with a reasonable IP. It does not check that the IP address is routable or reserved.

SEE ALSO

Top

CGI::Untaint

AUTHOR

Top

Simon Cozens, simon@kasei.com

COPYRIGHT

Top


CGI-Untaint-ipaddress documentation Contained in the CGI-Untaint-ipaddress distribution.

package CGI::Untaint::ipaddress;

use strict;
use base 'CGI::Untaint::object';

use vars qw/$VERSION/;
$VERSION = '0.01';

sub _untaint_re { 
  return qr/^((?:(?:25[0-5]|2[0-4]\d|[0-1]??\d{1,2})[.](?:25[0-5]|2[0-4]\d|[0-1]??\d{1,2})[.](?:25[0-5]|2[0-4]\d|[0-1]??\d{1,2})[.](?:25[0-5]|2[0-4]\d|[0-1]??\d{1,2})))$/i;
}

1;