X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Flib%2FRT%2FObjectCustomFieldValue.pm;h=0e63ced1b6e8d125eaa8797d7b2520f1138ce4dd;hb=008524b8e963831999983769f7fec11f55a72f16;hp=0fd9d735c3a99b96b6165dba7b702aaa1ad80270;hpb=43a06151e47d2c59b833cbd8c26d97865ee850b6;p=freeside.git diff --git a/rt/lib/RT/ObjectCustomFieldValue.pm b/rt/lib/RT/ObjectCustomFieldValue.pm index 0fd9d735c..0e63ced1b 100644 --- a/rt/lib/RT/ObjectCustomFieldValue.pm +++ b/rt/lib/RT/ObjectCustomFieldValue.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -84,36 +84,11 @@ sub Create { @_, ); + 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'}); - - 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; - } - } + my ($val, $msg) = $cf->_CanonicalizeValue(\%args); + return ($val, $msg) unless $val; if ( defined $args{'Content'} && length( Encode::encode_utf8($args{'Content'}) ) > 255 ) { if ( defined $args{'LargeContent'} && length $args{'LargeContent'} ) { @@ -164,16 +139,9 @@ sub LoadByCols { 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); } @@ -251,6 +219,8 @@ my $re_ip_serialized = qr/$re_ip_sunit(?:\.$re_ip_sunit){3}/; sub Content { my $self = shift; + return undef unless $self->CustomFieldObj->CurrentUserHasRight('SeeCustomField'); + my $content = $self->_Value('Content'); if ( $self->CustomFieldObj->Type eq 'IPAddress' || $self->CustomFieldObj->Type eq 'IPAddressRange' ) @@ -364,11 +334,11 @@ sub _FillInTemplateURL { # special case, whole value should be an URL if ( $url =~ /^__CustomField__/ ) { my $value = $self->Content; - # protect from javascript: URLs - if ( $value =~ /^\s*javascript:/i ) { + # protect from potentially malicious URLs + if ( $value =~ /^\s*(?:javascript|data):/i ) { my $object = $self->Object; $RT::Logger->error( - "Dangerouse value with JavaScript in custom field '". $self->CustomFieldObj->Name ."'" + "Potentially dangerous URL type in custom field '". $self->CustomFieldObj->Name ."'" ." on ". ref($object) ." #". $object->id ); return undef;