summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Attachment_Overlay.pm
diff options
context:
space:
mode:
authorivan <ivan>2004-03-11 02:05:38 +0000
committerivan <ivan>2004-03-11 02:05:38 +0000
commit289340780927b5bac2c7604d7317c3063c6dd8cc (patch)
treec4100ab9857ae00c330213af8a46e66c208580e6 /rt/lib/RT/Attachment_Overlay.pm
parent945721f48f74d5cfffef7c7cf3a3d6bc2521f5dd (diff)
import of rt 3.0.9RT_3_0_9
Diffstat (limited to 'rt/lib/RT/Attachment_Overlay.pm')
-rw-r--r--rt/lib/RT/Attachment_Overlay.pm39
1 files changed, 30 insertions, 9 deletions
diff --git a/rt/lib/RT/Attachment_Overlay.pm b/rt/lib/RT/Attachment_Overlay.pm
index d31aa75..9086c52 100644
--- a/rt/lib/RT/Attachment_Overlay.pm
+++ b/rt/lib/RT/Attachment_Overlay.pm
@@ -112,8 +112,8 @@ sub Create {
#For ease of reference
my $Attachment = $args{'Attachment'};
- #if we didn't specify a ticket, we need to bail
- if ( $args{'TransactionId'} == 0 ) {
+ #if we didn't specify a ticket, we need to bail
+ if ( $args{'TransactionId'} == 0 ) {
$RT::Logger->crit( "RT::Attachment->Create couldn't, as you didn't specify a transaction\n" );
return (0);
@@ -133,7 +133,9 @@ sub Create {
=~ /^.*\bfilename="(.*)"$/ ? $1 : ''
};
- if ( $Attachment->parts ) {
+ # If a message has no bodyhandle, that means that it has subparts (or appears to)
+ # and we should act accordingly.
+ unless ( defined $Attachment->bodyhandle ) {
$id = $self->SUPER::Create(
TransactionId => $args{'TransactionId'},
Parent => 0,
@@ -241,6 +243,9 @@ Create an attachment exactly as specified in the named parameters.
sub Import {
my $self = shift;
+ my %args = ( ContentEncoding => 'none',
+
+ @_ );
return($self->SUPER::Create(@_));
}
@@ -309,11 +314,15 @@ sub OriginalContent {
}
# Encode::_utf8_on($content);
- if (!$enc or $enc eq 'utf8' or $enc eq 'utf-8') {
+ if (!$enc || $enc eq '' || $enc eq 'utf8' || $enc eq 'utf-8') {
# If we somehow fail to do the decode, at least push out the raw bits
eval {return( Encode::decode_utf8($content))} || return ($content);
}
- Encode::from_to($content, 'utf8' => $enc);
+
+ eval { Encode::from_to($content, 'utf8' => $enc);};
+ if ($@) {
+ $RT::Logger->error("Could not convert attachment from assumed utf8 to '$enc' :".$@);
+ }
return $content;
}
@@ -423,10 +432,13 @@ properly unfolded.
=cut
sub NiceHeaders {
- my $self=shift;
- my $hdrs="";
- for (split(/\n/,$self->Headers)) {
- $hdrs.="$_\n" if /^(To|From|RT-Send-Cc|Cc|Date|Subject): /i
+ my $self = shift;
+ my $hdrs = "";
+ my @hdrs = split(/\n/,$self->Headers);
+ while (my $str = shift @hdrs) {
+ next unless $str =~ /^(To|From|RT-Send-Cc|Cc|Date|Subject): /i;
+ $hdrs .= $str . "\n";
+ $hdrs .= shift( @hdrs ) . "\n" while ($hdrs[0] =~ /^[ \t]+/);
}
return $hdrs;
}
@@ -568,4 +580,13 @@ sub ContentLength {
# }}}
+# Transactions don't change. by adding this cache congif directiove, we don't lose pathalogically on long tickets.
+sub _CacheConfig {
+ {
+ 'cache_p' => 1,
+ 'fast_update_p' => 1,
+ 'cache_for_sec' => 180,
+ }
+}
+
1;