X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=9eb1c9aebfad64599dbfb983068a03e4100c6b5b;hb=289c2643882c611a068fffd06e42e258264844e8;hp=9dd08cfd8a94c0a97872f378befe310809a5a350;hpb=b6088672c87e2c5984183326b4c0e2d9bd6c34f6;p=freeside.git diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 9dd08cfd8..9eb1c9aeb 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -286,6 +286,11 @@ the individual PARAMS_HASHREF queries #regular FS::TABLE methods #on it. +C<$FS::Record::qsearch_qualify_columns> package global is enabled by default. +When enabled, the WHERE clause generated from the 'hashref' parameter has +the table name prepended to each column name. WHERE column = 'value' becomes +WHERE table.coumn = 'value' + =cut my %TYPE = (); #for debugging @@ -2911,18 +2916,9 @@ Check/untaint IPv4 or IPv6 address. sub ut_ip46 { my( $self, $field ) = @_; - my $ip_addr = $self->getfield( $field ); - - # strip user-entered leading 0's from IPv4 addresses - # Parsers like NetAddr::IP interpret them as octal instead of decimal - $ip_addr = join( '.', ( - map{ int($_) } - split( /\./, $ip_addr ) - ) - ) if $ip_addr =~ /\./ && $ip_addr =~ /[\.^]0/; - - my $ip = NetAddr::IP->new( $ip_addr ) - or return "Illegal (IP address) $field: ".$self->getfield($field); + my $ip = NetAddr::IP->new( + $self->_ut_ip_strip_leading_zeros( $self->getfield( $field ) ) + ) or return "Illegal (IP address) $field: ".$self->getfield($field); $self->setfield($field, lc($ip->addr)); return ''; } @@ -2942,6 +2938,21 @@ sub ut_ip46n { $self->ut_ip46($field); } +sub _ut_ip_strip_leading_zeros { + # strip user-entered leading 0's from IP addresses + # so parsers like NetAddr::IP don't mangle the address + # e.g. NetAddr::IP converts 10.0.022.220 into 10.0.18.220 + + my ( $self, $ip ) = @_; + + return join '.', map int, split /\./, $ip + if $ip + && $ip =~ /\./ + && $ip =~ /[\.^]0/; + $ip; +} + + =item ut_coord COLUMN [ LOWER [ UPPER ] ] Check/untaint coordinates.