The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


CGI::Untaint::hostname - untaint DNS host names


  use CGI::Untaint::hostname
  my $handler = CGI::Untaint->new( $q->Vars() );
  my $filename = $handler->extract( -as_hostname => '' );


This module untaints and validates DNS host names. Validation means that the name has the correct syntax specified in RFC 1035 section 3.5 (page 10), not that it exists (after all you could use this in a web front-end to a dns zone maintenance system) anywhere in any form.


to install the module...

perl Build.PL ./Build ./Build test ./Build install


None known.


E-mail the author


        Dana Hudes


This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.


perl(1), CGI::Untaint, RFC 1035.


 Usage     : $self->is_valid
 Purpose   : Ensure that the hostname name is completely valid including length checking
 Returns   : true if the name is valid
 Argument  : the string to validate is in $self object
 Throws    : nothing
 Comments  :

See Also : is_ok


 Usage     : $self->is_ok($value)
 Purpose   : Perform syntax and length checking to validate the name
 Returns   : true if the name is valid
 Argument  : the string to validate
 Throws    : nothing of its own
 Comments  : RFC 1304 section 3.5 specificies the syntax and length limits on the names. Each section, separated by '.',
           : must start with a letter, end with a letter or digit, and have as interior
           : characters only letters, digits, and hyphen. The length of each section is  63 characters maximum.
           : While it is customary to have a two or three letter "top-level domain" suffix, this is not
           : required (cf ".arpa") 
           : N.B. while empirically it seems that registrars are registering names starting with digits, (e.g., I find no 
           : basis for this in any RFC.
See Also   : is_ok