[Rt-commit] rt branch, 4.2/ip-address-canonicalization, repushed

Alex Vandiver alexmv at bestpractical.com
Thu Jun 5 16:26:58 EDT 2014


The branch 4.2/ip-address-canonicalization was deleted and repushed:
       was 3e8172a980fe4c30cd2db07804c24c09941e442b
       now cd94a08cbb807b16ccf985501085db3cf658a380

 1:  8bafa98 =  1:  5e2dc55 ->Content is as formatted for the user, not the DB value
 2:  c899c7d =  2:  66cf1d4 Add a generic ->_CanonicalizeValue
--:  ------- >  3:  d3928d7 Move canonicalization into RT::ObjectCustomFieldValue->Create
 3:  3aabe6f !  4:  c1727f6 Add common IP address and range canonicalizers
    @@ -1,29 +1,16 @@
     Author: Alex Vandiver <alexmv at bestpractical.com>
     
    -    Refactor IP canonicalizers in Create into standard methods
    +    Add common IP address and range canonicalizers
         
    -    The IP address and range code in ObjectCustomFieldValue's Create is
    -    moved into the more general canonicalization functions.  This also
    -    allows HasEntry can split IP ranges correctly to check their existance,
    -    and ensures that the standard form (padded to three digits per octet) is
    -    compared against the database.
    -    
    -    This additionally ensures that invalid Date and DateTime CF values
    -    cannot be created directly via ObjectCustomFieldValue->Create; they were
    -    previously cleaned up only at the ->AddValueForObject level.
    +    The IP address and range canonicalization in ObjectCustomFieldValue's
    +    Create is moved into the more general canonicalization functions.  This
    +    also allows HasEntry can split IP ranges correctly to check their
    +    existance, and ensures that the standard form (padded to three digits
    +    per octet) is compared against the database.
     
     diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
     --- a/lib/RT/CustomField.pm
     +++ b/lib/RT/CustomField.pm
    -@@
    -         }
    -     }
    - 
    --    $self->_CanonicalizeValue(\%args);
    --
    -     my $newval = RT::ObjectCustomFieldValue->new( $self->CurrentUser );
    -     my ($val, $msg) = $newval->Create(
    -         ObjectType   => ref($obj),
     @@
          $args->{'Content'} = $DateObj->Date( Timezone => 'user' );
      }
    @@ -56,17 +43,10 @@
     --- a/lib/RT/ObjectCustomFieldValue.pm
     +++ b/lib/RT/ObjectCustomFieldValue.pm
     @@
    -         @_,
    -     );
      
    -+    my $cf = RT::CustomField->new( $self->CurrentUser );
    -+    $cf->Load( $args{CustomField} );
    -+    return (0, $self->loc("Invalid custom field")) unless $cf->id;
    +     $cf->_CanonicalizeValue(\%args);
      
    --    my $cf_as_sys = RT::CustomField->new(RT->SystemUser);
    --    $cf_as_sys->Load($args{'CustomField'});
    --
    --    if($cf_as_sys->Type eq 'IPAddress') {
    +-    if($cf->_Value('Type') eq 'IPAddress') {
     -        if ( $args{'Content'} ) {
     -            $args{'Content'} = $self->ParseIP( $args{'Content'} );
     -        }
    @@ -79,7 +59,7 @@
     -        }
     -    }
     -
    --    if($cf_as_sys->Type eq 'IPAddressRange') {
    +-    if($cf->_Value('Type') eq 'IPAddressRange') {
     -        if ($args{'Content'}) {
     -            ($args{'Content'}, $args{'LargeContent'}) = $self->ParseIPRange( $args{'Content'} );
     -        }
    @@ -92,8 +72,8 @@
     -              : 0;
     -        }
     -    }
    -+    $cf->_CanonicalizeValue(\%args);
    - 
    +-
          if ( defined $args{'Content'} && length( Encode::encode_utf8($args{'Content'}) ) > 255 ) {
              if ( defined $args{'LargeContent'} && length $args{'LargeContent'} ) {
    +             $RT::Logger->error("Content is longer than 255 bytes and LargeContent specified");
     
 4:  d8093d1 !  5:  b7a8c03 Let canonicalization return a failure message
    @@ -10,13 +10,13 @@
     --- a/lib/RT/CustomField.pm
     +++ b/lib/RT/CustomField.pm
     @@
    -     my $self = shift;
          my $args = shift;
      
    --    return unless $self->Type;
    -+    return 1 unless $self->Type;
    +     my $type = $self->_Value('Type');
    +-    return unless $type;
    ++    return 1 unless $type;
      
    -     my $method = '_CanonicalizeValue'.$self->Type;
    +     my $method = '_CanonicalizeValue'. $type;
     -    return unless $self->can($method);
     +    return 1 unless $self->can($method);
          $self->$method($args);
    @@ -63,8 +63,8 @@
     --- a/lib/RT/ObjectCustomFieldValue.pm
     +++ b/lib/RT/ObjectCustomFieldValue.pm
     @@
    +     my $cf = RT::CustomField->new( $self->CurrentUser );
          $cf->Load( $args{CustomField} );
    -     return (0, $self->loc("Invalid custom field")) unless $cf->id;
      
     -    $cf->_CanonicalizeValue(\%args);
     +    my ($val, $msg) = $cf->_CanonicalizeValue(\%args);
 5:  b3fd2ea =  6:  4047873 Provide a better error message for loading OCFVs on an invalid CF
 6:  2d09642 =  7:  8ed92ae Canonicalize all OCFVs on load, not just IP address ranges
 7:  f48a6ee =  8:  cd370c4 Remove too-many-value OCFVs by id, not Content
 8:  d825f22 =  9:  d0cef42 Reuse existing validation in OCVF canonicalization
 9:  3e8172a = 10:  cd94a08 Remove a needless block; ParseIPRange does the exact same as its first step



More information about the rt-commit mailing list