Commit 9cc181ba authored by Alex Vandiver's avatar Alex Vandiver
Browse files

Add RT::Util::assert_bytes checks to _EncodeLOB and _DecodeLOB

929b4231 specifically documented _EncodeLOB and _DecodeLOB to take
bytes; enforce that by checking the arguments they are passed using
RT::Util::assert_bytes.
parent 3ac9388d
...@@ -775,6 +775,8 @@ sub _EncodeLOB { ...@@ -775,6 +775,8 @@ sub _EncodeLOB {
my $ContentEncoding = 'none'; my $ContentEncoding = 'none';
my $note_args; my $note_args;
RT::Util::assert_bytes( $Body );
#get the max attachment length from RT #get the max attachment length from RT
my $MaxSize = RT->Config->Get('MaxAttachmentSize'); my $MaxSize = RT->Config->Get('MaxAttachmentSize');
...@@ -837,13 +839,10 @@ sub _EncodeLOB { ...@@ -837,13 +839,10 @@ sub _EncodeLOB {
# if we need to mimencode the attachment # if we need to mimencode the attachment
if ( $ContentEncoding eq 'base64' ) { if ( $ContentEncoding eq 'base64' ) {
# base64 encode the attachment # base64 encode the attachment
Encode::_utf8_off($Body);
$Body = MIME::Base64::encode_base64($Body); $Body = MIME::Base64::encode_base64($Body);
} elsif ($ContentEncoding eq 'quoted-printable') { } elsif ($ContentEncoding eq 'quoted-printable') {
Encode::_utf8_off($Body);
$Body = MIME::QuotedPrint::encode($Body); $Body = MIME::QuotedPrint::encode($Body);
} }
...@@ -884,6 +883,8 @@ sub _DecodeLOB { ...@@ -884,6 +883,8 @@ sub _DecodeLOB {
my $ContentEncoding = shift || 'none'; my $ContentEncoding = shift || 'none';
my $Content = shift; my $Content = shift;
RT::Util::assert_bytes( $Content );
if ( $ContentEncoding eq 'base64' ) { if ( $ContentEncoding eq 'base64' ) {
$Content = MIME::Base64::decode_base64($Content); $Content = MIME::Base64::decode_base64($Content);
} }
...@@ -900,7 +901,7 @@ sub _DecodeLOB { ...@@ -900,7 +901,7 @@ sub _DecodeLOB {
my $charset = RT::I18N::_FindOrGuessCharset($entity); my $charset = RT::I18N::_FindOrGuessCharset($entity);
$charset = 'utf-8' if not $charset or not Encode::find_encoding($charset); $charset = 'utf-8' if not $charset or not Encode::find_encoding($charset);
$Content = Encode::decode($charset,$Content,Encode::FB_PERLQQ) unless Encode::is_utf8($Content); $Content = Encode::decode($charset,$Content,Encode::FB_PERLQQ);
} }
return ($Content); return ($Content);
} }
......
Markdown is supported
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