Changeset 139


Ignore:
Timestamp:
Oct 23, 2006, 3:34:48 PM (13 years ago)
Author:
Dominic Hargreaves
Message:

Should fix #17

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/cgi/submit.fcgi

    r130 r139  
    8282
    8383    # Now validate the postcode input format
    84     my $raw_postcode = $cgi->param('postcode1');
    85     $raw_postcode .= ' ' . $cgi->param('postcode2') if defined $cgi->param('postcode2');
    86     my $trimmed_postcode = $raw_postcode;
    87     $trimmed_postcode =~ s/^\s+//;
    88     $trimmed_postcode =~ s/\s+$//;
    89     my $postcode = Geo::Postcode->new($trimmed_postcode);
     84    my ($trimmed_1, $trimmed_2) = ($cgi->param('postcode1'), $cgi->param('postcode2'));
     85    $trimmed_1 =~ s/^\s+//;
     86    $trimmed_2 =~ s/^\s+//;
     87    $trimmed_1 =~ s/\s+$//;
     88    $trimmed_2 =~ s/\s+$//;
     89    my $raw_postcode = $trimmed_1;
     90    $raw_postcode .= ' ' . $trimmed_2 if defined $trimmed_2;
     91
     92    unless (length(($trimmed_2)) == 1 or (length($trimmed_2) == 3) or (!defined $trimmed_2)) {
     93        print_err("The postcode format is not valid", $returnlink);
     94        next REQUEST;
     95    }
     96
     97    my $postcode = Geo::Postcode->new($raw_postcode);
    9098    my ($first, $second, $third, $fourth) = @{$postcode->fragments};
    9199    my ($outward, $inward);
Note: See TracChangeset for help on using the changeset viewer.