Commit 0fa35838 authored by Jesse Vincent's avatar Jesse Vincent
Browse files

Adding support for encoding LOBs for the new custom field behaviour

git-svn-id: svn+ssh://svn.bestpractical.com/svn/bps-public/rt/branches/rt-3.3@707 e417ac7c-1bcc-0310-8ffa-8f5827389a85
parent 6ac0813a
......@@ -212,26 +212,7 @@ before returning it.
sub Content {
my $self = shift;
my $decode_utf8 = (($self->ContentType eq 'text/plain') ? 1 : 0);
if ( $self->ContentEncoding eq 'none' || ! $self->ContentEncoding ) {
return $self->_Value(
'Content',
decode_utf8 => $decode_utf8,
);
} elsif ( $self->ContentEncoding eq 'base64' ) {
return ( $decode_utf8
? Encode::decode_utf8(MIME::Base64::decode_base64($self->_Value('Content')))
: MIME::Base64::decode_base64($self->_Value('Content'))
);
} elsif ( $self->ContentEncoding eq 'quoted-printable' ) {
return ( $decode_utf8
? Encode::decode_utf8(MIME::QuotedPrint::decode($self->_Value('Content')))
: MIME::QuotedPrint::decode($self->_Value('Content'))
);
} else {
return( $self->loc("Unknown ContentEncoding [_1]", $self->ContentEncoding));
}
$self->_DecodeLOB($self->ContentType, $self->ContentEncoding, $self->_Value('Content', decode_utf8 => 0));
}
......
......@@ -25,6 +25,45 @@ use strict;
no warnings qw(redefine);
sub Create {
my $self = shift;
my %args = (
CustomField => '0',
ObjectType => '',
ObjectId => '0',
Current => '1',
Content => '',
LargeContent => '',
ContentType => '',
ContentEncoding => '',
@_);
($args{'ContentEncoding'}, $args{'LargeContent'}) = $self->_EncodeLOB($args{'LargeContent'}, $args{'ContentType'}) if ($args{'LargeContent'});
$self->SUPER::Create(
CustomField => $args{'CustomField'},
ObjectType => $args{'ObjectType'},
ObjectId => $args{'ObjectId'},
Current => $args{'Current'},
Content => $args{'Content'},
LargeContent => $args{'LargeContent'},
ContentType => $args{'ContentType'},
ContentEncoding => $args{'ContentEncoding'},
);
}
sub LargeContent {
my $self = shift;
$self->_DecodeLOB( $self->ContentType, $self->ContentEncoding,
$self->_Value( 'LargeContent', decode_utf 8 => 0 ) );
}
=head2 LoadByTicketContentAndCustomField { Ticket => TICKET, CustomField => CUSTOMFIELD, Content => CONTENT }
......
......@@ -676,6 +676,28 @@ sub _EncodeLOB {
}
sub _DecodeLOB {
my $self = shift;
my $ContentType = shift;
my $ContentEncoding = shift;
my $Content = shift;
if ( $ContentEncoding eq 'base64' ) {
$Content = MIME::Base64::decode_base64($Content);
}
elsif ( $ContentEncoding eq 'quoted-printable' ) {
$Content = MIME::QuotedPrint::decode($Content);
}
elsif ( $ContentEncoding && $ContentEncoding ne 'none' ) {
return ( $self->loc( "Unknown ContentEncoding [_1]", $ContentEncoding ) );
}
if ( $ContentType eq 'text/plain' ) {
return Encode::decode_utf8($Content);
}
else {
return ($Content);
}
}
# {{{ LINKDIRMAP
# A helper table for relationships mapping to make it easier
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment