sub OriginalContent {
my $self = shift;
- return $self->Content unless (
- $self->ContentType =~ qr{^(text/plain|message/rfc822)$}i) ;
+ return $self->Content unless RT::I18N::IsTextualContentType($self->ContentType);
+
my $enc = $self->OriginalEncoding;
my $content;
} elsif ( $self->ContentEncoding eq 'base64' ) {
$content = MIME::Base64::decode_base64($self->_Value('Content', decode_utf8 => 0));
} elsif ( $self->ContentEncoding eq 'quoted-printable' ) {
- return MIME::QuotedPrint::decode($self->_Value('Content', decode_utf8 => 0));
+ $content = MIME::QuotedPrint::decode($self->_Value('Content', decode_utf8 => 0));
} else {
return( $self->loc("Unknown ContentEncoding [_1]", $self->ContentEncoding));
}
- Encode::_utf8_on($content);
+ # Turn *off* the SvUTF8 bits here so decode_utf8 and from_to below can work.
+ local $@;
+ Encode::_utf8_off($content);
+
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);
# TODO: Handle Multipart/Mixed (eventually fix the link in the
# ShowHistory web template?)
- if ($self->ContentType =~ m{^(text/plain|message)}i) {
+ if (RT::I18N::IsTextualContentType($self->ContentType)) {
$body=$self->Content;
# Do we need any preformatting (wrapping, that is) of the message?