coordinates can be negative (deja vu?)
authorjeff <jeff>
Fri, 16 Feb 2007 20:21:54 +0000 (20:21 +0000)
committerjeff <jeff>
Fri, 16 Feb 2007 20:21:54 +0000 (20:21 +0000)
FS/FS/Record.pm
FS/FS/svc_broadband.pm

index 4efaeff..94cc356 100644 (file)
@@ -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,
index ab97ac8..07821f9 100755 (executable)
@@ -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;