#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@_,
);
+ my $cf = RT::CustomField->new( $self->CurrentUser );
+ $cf->Load( $args{CustomField} );
- my $cf_as_sys = RT::CustomField->new(RT->SystemUser);
- $cf_as_sys->Load($args{'CustomField'});
+ my ($val, $msg) = $cf->_CanonicalizeValue(\%args);
+ return ($val, $msg) unless $val;
- if($cf_as_sys->Type eq 'IPAddress') {
- if ( $args{'Content'} ) {
- $args{'Content'} = $self->ParseIP( $args{'Content'} );
- }
-
- unless ( defined $args{'Content'} ) {
- return
- wantarray
- ? ( 0, $self->loc("Content is an invalid IP address") )
- : 0;
- }
- }
-
- if($cf_as_sys->Type eq 'IPAddressRange') {
- if ($args{'Content'}) {
- ($args{'Content'}, $args{'LargeContent'}) = $self->ParseIPRange( $args{'Content'} );
- }
- $args{'ContentType'} = 'text/plain';
-
- unless ( defined $args{'Content'} ) {
- return
- wantarray
- ? ( 0, $self->loc("Content is an invalid IP address range") )
- : 0;
- }
- }
-
- if ( defined $args{'Content'} && length( Encode::encode_utf8($args{'Content'}) ) > 255 ) {
+ my $encoded = Encode::encode("UTF-8", $args{'Content'});
+ if ( defined $args{'Content'} && length( $encoded ) > 255 ) {
if ( defined $args{'LargeContent'} && length $args{'LargeContent'} ) {
$RT::Logger->error("Content is longer than 255 bytes and LargeContent specified");
}
if ( $args{CustomField} ) {
$cf = RT::CustomField->new( $self->CurrentUser );
$cf->Load( $args{CustomField} );
- if ( $cf->Type && $cf->Type eq 'IPAddressRange' ) {
-
- my ( $sIP, $eIP ) = $cf->ParseIPRange( $args{'Content'} );
- if ( $sIP && $eIP ) {
- $self->SUPER::LoadByCols( %args,
- Content => $sIP,
- LargeContent => $eIP
- );
- }
- }
+
+ my ($ok, $msg) = $cf->_CanonicalizeValue(\%args);
+ return ($ok, $msg) unless $ok;
}
return $self->SUPER::LoadByCols(%args);
}