X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=2fec8e00f2f4c10d0ba8dde051b372d78cd2489a;hp=bccc8e6d4ea454f322f976228efc4c9072ed931d;hb=14c5096e04f0d1ac2a19a3c6c41e537a9aa0f78c;hpb=ce18f284969a1eaed7985a91123a275a57090e12 diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index bccc8e6d4..2fec8e00f 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -2385,6 +2385,42 @@ sub ut_hexn { $self->setfield($field, uc($1)); ''; } + +=item ut_mac_addr COLUMN + +Check/untaint mac addresses. May be null. + +=cut + +sub ut_mac_addr { + my($self, $field) = @_; + + my $mac = $self->get($field); + $mac =~ s/\s+//g; + $mac =~ s/://g; + $self->set($field, $mac); + + my $e = $self->ut_hex($field); + return $e if $e; + + return "Illegal (mac address) $field: ". $self->getfield($field) + unless length($self->getfield($field)) == 12; + + ''; + +} + +=item ut_mac_addrn COLUMN + +Check/untaint mac addresses. May be null. + +=cut + +sub ut_mac_addrn { + my($self, $field) = @_; + ($self->getfield($field) eq '') ? '' : $self->ut_mac_addr($field); +} + =item ut_ip COLUMN Check/untaint ip addresses. IPv4 only for now, though ::1 is auto-translated