Skip to content

Commit

Permalink
Preserve original email if encoding is not required
Browse files Browse the repository at this point in the history
GH #52
  • Loading branch information
atoomic committed Sep 6, 2017
1 parent 9107810 commit 7986a6c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/Email/MIME/Encode.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use strict;
use warnings;
package Email::MIME::Encode;
# ABSTRACT: a private helper for MIME header encoding

use Carp ();
use Encode ();
use MIME::Base64();
Expand All @@ -26,14 +25,14 @@ sub maybe_mime_encode_header {
header_name_length => $header_name_length,
});
}

return _object_encode($val, $charset, $header_name_length, $Email::MIME::Header::header_to_class_map{$header})
if exists $Email::MIME::Header::header_to_class_map{$header};

my $min_wrap_length = 78 - $header_name_length + 1;

return $val
unless _needs_mime_encode($val) || $val =~ /[^\s]{$min_wrap_length,}/;
if !ref $val && !_needs_mime_encode_addr($val) && $val !~ /[^\s]{$min_wrap_length,}/;


return _object_encode($val, $charset, $header_name_length, $Email::MIME::Header::header_to_class_map{$header})
if exists $Email::MIME::Header::header_to_class_map{$header};

return $val
if exists $no_mime_headers{$header};
Expand Down

0 comments on commit 7986a6c

Please sign in to comment.