[Rt-commit] rt branch, 4.4/txn-content-skip-mime-attachments, repushed

? sunnavy sunnavy at bestpractical.com
Thu May 2 12:41:06 EDT 2019


The branch 4.4/txn-content-skip-mime-attachments was deleted and repushed:
       was 0c43d45b6e0066cc2272fa06b51e7511eef6cdea
       now 7ac5b6859a7a095283bbfa9c4a7e604642c9b157

1: 233952a23 ! 1: d6d4629df Exclude MIME attachments when questing a transaction's content
    @@ -12,18 +12,22 @@
      C<$RT::Transaction::PreferredContentType>, if that's missing too, 
      defaults to textual.
      
    -+All the MIME attachments(ones with suggested filenames) are excluded here,
    -+because it doesn't make much sense to use them as transaction content.
    ++All the MIME attachments are excluded here, because it doesn't make much sense
    ++to use them as transaction content.
     +
      =cut
      
      sub Content {
     @@
    +     # displayable".  For now, this maintains backcompat
          my $all_parts = $self->Attachments;
          while ( my $part = $all_parts->Next ) {
    -         next unless _IsDisplayableTextualContentType($part->ContentType)
    +-        next unless _IsDisplayableTextualContentType($part->ContentType)
     -        && $part->Content;
    -+        && !$part->Filename && $part->Content;
    ++        next unless _IsDisplayableTextualContentType( $part->ContentType )
    ++          && !$part->Filename
    ++          && ( $part->GetHeader('Content-Disposition') // '' ) !~ /^\s*attachment\b/i
    ++          && $part->Content;
              return $part;
          }
      
    @@ -33,6 +37,7 @@
      
     +    # If it's a MIME attachment, return undef.
     +    return undef if $Attachment->Filename;
    ++    return undef if ( $Attachment->GetHeader('Content-Disposition') // '' ) =~ /^\s*attachment\b/i;
     +
          # If it's a textual part, just return the body.
          if ( _IsDisplayableTextualContentType($Attachment->ContentType) ) {
2: 0c43d45b6 ! 2: 7ac5b6859 Add tests for transaction content
    @@ -55,6 +55,48 @@
     +    );
     +    push @mime,
     +      { object => $mime, expected => 'This transaction appears to have no content', description => 'has an attachment but no main part' };
    ++
    ++    my $parser = MIME::Parser->new();
    ++    $parser->output_to_core(1);
    ++    $mime = $parser->parse_data( <<EOF );
    ++Content-Type: multipart/mixed; boundary="=-=-="
    ++
    ++--=-=-=
    ++Content-Type: message/rfc822
    ++Content-Disposition: inline
    ++
    ++Content-Type: text/plain
    ++Subject: test
    ++
    ++main body
    ++--=-=-=
    ++EOF
    ++
    ++    push @mime, { object => $mime, expected => "main body", description => 'has an rfc822 message' };
    ++
    ++    $mime = $parser->parse_data( <<EOF );
    ++Content-Type: multipart/mixed; boundary="=-=-="
    ++
    ++--=-=-=
    ++Content-Type: message/rfc822
    ++Content-Disposition: attachment
    ++
    ++Content-Type: text/plain
    ++Subject: test
    ++
    ++inner body of rfc822
    ++
    ++--=-=-=
    ++Content-Type: text/plain
    ++Subject: test
    ++
    ++main body
    ++--=-=-=
    ++
    ++EOF
    ++
    ++    push @mime,
    ++      { object => $mime, expected => 'main body', description => 'has an attachment of rfc822 message and main part' };
     +
     +    for my $mime ( @mime ) {
     +        my $ticket = RT::Ticket->new( RT->SystemUser );



More information about the rt-commit mailing list