diff options
author | jeff <jeff> | 2007-02-16 20:21:54 +0000 |
---|---|---|
committer | jeff <jeff> | 2007-02-16 20:21:54 +0000 |
commit | d573497e75bd5bbc65915be4b441b6f162cc9808 (patch) | |
tree | f6c4ec2babff98cc70dca838ab344822979b1c0a | |
parent | 0dbc5284b650523d7bf299fa86279b21b0325a9d (diff) |
coordinates can be negative (deja vu?)
-rw-r--r-- | FS/FS/Record.pm | 35 | ||||
-rwxr-xr-x | FS/FS/svc_broadband.pm | 6 |
2 files changed, 38 insertions, 3 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 4efaeffdc..94cc356e5 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1338,6 +1338,41 @@ sub ut_floatn { } } +=item ut_sfloat COLUMN + +Check/untaint signed floating point numeric data: 1.1, 1, 1.1e10, 1e10. +May not be null. If there is an error, returns the error, otherwise returns +false. + +=cut + +sub ut_sfloat { + my($self,$field)=@_ ; + ($self->getfield($field) =~ /^(-?\d+\.\d+)$/ || + $self->getfield($field) =~ /^(-?\d+)$/ || + $self->getfield($field) =~ /^(-?\d+\.\d+[eE]-?\d+)$/ || + $self->getfield($field) =~ /^(-?\d+[eE]-?\d+)$/) + or return "Illegal or empty (float) $field: ". $self->getfield($field); + $self->setfield($field,$1); + ''; +} +=item ut_sfloatn COLUMN + +Check/untaint signed floating point numeric data: 1.1, 1, 1.1e10, 1e10. May be +null. If there is an error, returns the error, otherwise returns false. + +=cut + +sub ut_sfloatn { + my( $self, $field ) = @_; + if ( $self->getfield($field) =~ /^()$/ ) { + $self->setfield($field,''); + ''; + } else { + $self->ut_sfloat($field); + } +} + =item ut_snumber COLUMN Check/untaint signed numeric data (whole numbers). If there is an error, diff --git a/FS/FS/svc_broadband.pm b/FS/FS/svc_broadband.pm index ab97ac82c..07821f9f5 100755 --- a/FS/FS/svc_broadband.pm +++ b/FS/FS/svc_broadband.pm @@ -200,9 +200,9 @@ sub check { || $self->ut_ipn('ip_addr') || $self->ut_hexn('mac_addr') || $self->ut_hexn('auth_key') - || $self->ut_floatn('latitude') - || $self->ut_floatn('longitude') - || $self->ut_floatn('altitude') + || $self->ut_sfloatn('latitude') + || $self->ut_sfloatn('longitude') + || $self->ut_sfloatn('altitude') || $self->ut_textn('vlan_profile') ; return $error if $error; |