From d573497e75bd5bbc65915be4b441b6f162cc9808 Mon Sep 17 00:00:00 2001 From: jeff Date: Fri, 16 Feb 2007 20:21:54 +0000 Subject: [PATCH] coordinates can be negative (deja vu?) --- FS/FS/Record.pm | 35 +++++++++++++++++++++++++++++++++++ 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; -- 2.11.0