Show
Ignore:
Timestamp:
10/18/08 19:19:22 (3 months ago)
Author:
dom
Message:

Correctly validate web site URLs during edit and display,
and truncate URLs that are too long (fixes #21)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/OpenGuides/Utils.pm

    r1163 r1231  
    1111use URI::Escape; 
    1212use MIME::Lite; 
     13use Data::Validate::URI qw( is_web_uri ); 
    1314 
    1415=head1 NAME 
     
    377378 
    378379    # Now do our real validation 
    379     # Numeric tests 
    380380    foreach my $var (qw(os_x os_y)) { 
    381381        if ($q->param($var) and $q->param($var) !~ /^-?\d+$/) { 
     
    387387        if ($q->param($var) and $q->param($var) !~ /^-?\d+\.?(\d+)?$/) { 
    388388            push @fails, "$var must be numeric, was: " . $q->param($var); 
     389        } 
     390    } 
     391 
     392    if ( $q->param('website') and $q->param('website') ne 'http://' ) { 
     393        unless ( is_web_uri( $q->param('website') ) ) { 
     394            push @fails, $q->param('website') . ' is not a valid web URI'; 
    389395        } 
    390396    }