Import upstream version 0.920+git20201122.1.dd382f4
Debian Janitor
2 years ago
17 | 17 |
'IO::String' => '0',
|
18 | 18 |
'Pod::Usage' => '0',
|
19 | 19 |
# Others - Versioned
|
20 | |
'Email::MIME' => '1.949',
|
|
20 |
'Email::MIME' => '1.923',
|
21 | 21 |
'Email::MIME::ContentType' => '1.014',
|
22 | 22 |
'Email::Sender' => '1.3',
|
23 | 23 |
'Email::Simple' => '2.206',
|
22 | 22 |
"requires" : {
|
23 | 23 |
"Carp" : "0",
|
24 | 24 |
"Email::Address" : "0",
|
25 | |
"Email::MIME" : "1.949",
|
|
25 |
"Email::MIME" : "1.923",
|
26 | 26 |
"Email::MIME::ContentType" : "1.014",
|
27 | 27 |
"Email::Sender" : "1.3",
|
28 | 28 |
"Email::Simple" : "2.206",
|
|
67 | 67 |
}
|
68 | 68 |
},
|
69 | 69 |
"version" : "0.920",
|
70 | |
"x_serialization_backend" : "JSON::PP version 4.02"
|
|
70 |
"x_serialization_backend" : "JSON::PP version 4.04"
|
71 | 71 |
}
|
27 | 27 |
requires:
|
28 | 28 |
Carp: '0'
|
29 | 29 |
Email::Address: '0'
|
30 | |
Email::MIME: '1.949'
|
|
30 |
Email::MIME: '1.923'
|
31 | 31 |
Email::MIME::ContentType: '1.014'
|
32 | 32 |
Email::Sender: '1.3'
|
33 | 33 |
Email::Simple: '2.206'
|
2 | 2 |
use ExtUtils::MakeMaker;
|
3 | 3 |
WriteMakefile
|
4 | 4 |
(
|
5 | |
'NAME' => 'Email::Outlook::Message',
|
6 | |
'VERSION_FROM' => 'lib/Email/Outlook/Message.pm',
|
|
5 |
'INSTALLDIRS' => 'site',
|
7 | 6 |
'PREREQ_PM' => {
|
|
7 |
'Email::MIME::ContentType' => '1.014',
|
|
8 |
'File::Basename' => '0',
|
|
9 |
'Email::MIME' => '1.923',
|
|
10 |
'POSIX' => '0',
|
8 | 11 |
'Carp' => '0',
|
9 | 12 |
'Email::Address' => '0',
|
10 | |
'Email::MIME' => '1.949',
|
11 | |
'Email::MIME::ContentType' => '1.014',
|
|
13 |
'IO::All' => '0',
|
|
14 |
'Getopt::Long' => '0',
|
|
15 |
'Pod::Usage' => '0',
|
|
16 |
'Email::Simple' => '2.206',
|
|
17 |
'IO::String' => '0',
|
|
18 |
'Encode' => '0',
|
|
19 |
'Test::More' => '0',
|
12 | 20 |
'Email::Sender' => '1.3',
|
13 | |
'Email::Simple' => '2.206',
|
14 | |
'Encode' => '0',
|
15 | |
'File::Basename' => '0',
|
16 | |
'Getopt::Long' => '0',
|
17 | |
'IO::All' => '0',
|
18 | |
'IO::String' => '0',
|
19 | |
'OLE::Storage_Lite' => '0.14',
|
20 | |
'POSIX' => '0',
|
21 | |
'Pod::Usage' => '0',
|
22 | |
'Test::More' => '0'
|
|
21 |
'OLE::Storage_Lite' => '0.14'
|
23 | 22 |
},
|
24 | |
'INSTALLDIRS' => 'site',
|
|
23 |
'VERSION_FROM' => 'lib/Email/Outlook/Message.pm',
|
|
24 |
'PL_FILES' => {},
|
|
25 |
'NAME' => 'Email::Outlook::Message',
|
25 | 26 |
'EXE_FILES' => [
|
26 | 27 |
'script/msgconvert'
|
27 | |
],
|
28 | |
'PL_FILES' => {}
|
|
28 |
]
|
29 | 29 |
)
|
30 | 30 |
;
|
390 | 390 |
my ($self, $key, $property) = @_;
|
391 | 391 |
my ($encoding, $data) = @{$self->get_mapi_property($property)};
|
392 | 392 |
$self->{$key} = $self->_decode_mapi_property($encoding, $data);
|
|
393 |
$self->{"${key}_ENCODING"} = $encoding;
|
393 | 394 |
|
394 | 395 |
$self->{VERBOSE}
|
395 | 396 |
and $self->_log_property("Using ", $property, $key);
|
376 | 376 |
return;
|
377 | 377 |
}
|
378 | 378 |
|
|
379 |
sub _body_plain_character_set {
|
|
380 |
my $self = shift;
|
|
381 |
my $body_encoding = $self->{BODY_PLAIN_ENCODING};
|
|
382 |
$self->_body_character_set($body_encoding)
|
|
383 |
}
|
|
384 |
|
|
385 |
sub _body_html_character_set {
|
|
386 |
my $self = shift;
|
|
387 |
my $body_encoding = $self->{BODY_HTML_ENCODING};
|
|
388 |
$self->_body_character_set($body_encoding)
|
|
389 |
}
|
|
390 |
|
379 | 391 |
sub _body_character_set {
|
380 | 392 |
my $self = shift;
|
381 | |
return _codepage_to_charset($self->{CODEPAGE});
|
382 | |
}
|
383 | |
|
384 | |
sub _codepage_to_charset {
|
385 | |
my $codepage = shift;
|
386 | |
if (defined $codepage) {
|
|
393 |
my $body_encoding = shift;
|
|
394 |
my $codepage = $self->{CODEPAGE};
|
|
395 |
if (defined $body_encoding && $body_encoding eq "001F") {
|
|
396 |
return "UTF-8";
|
|
397 |
} elsif (defined $codepage) {
|
387 | 398 |
return $MAP_CODEPAGE->{$codepage} || "CP$codepage";
|
388 | |
}
|
389 | |
return 'CP1252';
|
|
399 |
} else {
|
|
400 |
return 'CP1252';
|
|
401 |
}
|
390 | 402 |
}
|
391 | 403 |
|
392 | 404 |
sub _create_mime_plain_body {
|
393 | 405 |
my $self = shift;
|
394 | |
my $charset = $self->_body_character_set;
|
|
406 |
my $charset = $self->_body_plain_character_set;
|
395 | 407 |
my $body_str = $self->{BODY_PLAIN};
|
396 | 408 |
if ($charset ne "UTF-8") {
|
397 | 409 |
# In this case, the body is a string of octets and needs to be decoded.
|
|
413 | 425 |
return Email::MIME->create(
|
414 | 426 |
attributes => {
|
415 | 427 |
content_type => "text/html",
|
416 | |
charset => $self->_body_character_set,
|
|
428 |
charset => $self->_body_html_character_set,
|
417 | 429 |
disposition => "inline",
|
418 | 430 |
encoding => "8bit",
|
419 | 431 |
},
|
19 | 19 |
|
20 | 20 |
my $text = $parts[0];
|
21 | 21 |
like($text->content_type, qr{^text/plain}, "Content type should be multipart/alternative");
|
22 | |
like($text->content_type, qr{; charset=CP1252}, "charset should be CP1252");
|
|
22 |
like($text->content_type, qr{; charset="?CP1252"?}, "charset should be CP1252");
|
23 | 23 |
is($text->header("Content-Disposition"), "inline", "Testing content disposition");
|
24 | 24 |
is($text->body, "This email contains an email\x85 Email-ception!!!\n\n", "Testing body");
|
25 | 25 |
is(scalar($text->subparts), 0, "No sub-parts");
|
26 | 26 |
my $html = $parts[1];
|
27 | 27 |
like($html->content_type, qr{^text/html}, "Content type should be text/html");
|
28 | |
like($text->content_type, qr{; charset=CP1252}, "charset should be CP1252");
|
|
28 |
like($text->content_type, qr{; charset="?CP1252"?}, "charset should be CP1252");
|
29 | 29 |
is($html->header("Content-Disposition"), "inline", "Testing content disposition");
|
30 | 30 |
is(scalar($html->subparts), 0, "No sub-parts");
|
57 | 57 |
sub test_to_email_mime_with_plain_part {
|
58 | 58 |
my $p = shift;
|
59 | 59 |
$p->{BODY_PLAIN} = "plain";
|
|
60 |
$p->{BODY_PLAIN_ENCODING} = "001E";
|
60 | 61 |
$p->{BODY_HTML} = undef;
|
61 | 62 |
my $m = $p->to_email_mime;
|
62 | 63 |
ok(defined $m);
|
63 | 64 |
ok(($m->parts) == 1);
|
64 | 65 |
is($m->body, "plain");
|
65 | |
is($m->content_type, "text/plain; charset=CP1252");
|
|
66 |
like($m->content_type, qr{^text/plain; charset="?CP1252"?$});
|
66 | 67 |
}
|
67 | 68 |
|
68 | 69 |
sub test_to_email_mime_with_html_part {
|
69 | 70 |
my $p = shift;
|
70 | 71 |
$p->{BODY_PLAIN} = undef;
|
71 | 72 |
$p->{BODY_HTML} = "html";
|
|
73 |
$p->{BODY_HTML_ENCODING} = "001E";
|
72 | 74 |
my $m = $p->to_email_mime;
|
73 | 75 |
ok(defined $m);
|
74 | 76 |
ok(($m->parts) == 1);
|
75 | 77 |
is($m->body, "html");
|
76 | |
is($m->content_type, "text/html; charset=CP1252");
|
|
78 |
like($m->content_type, qr{^text/html; charset="?CP1252"?$});
|
77 | 79 |
}
|
78 | 80 |
|
79 | 81 |
sub test_to_email_mime_with_two_parts {
|
80 | 82 |
my $p = shift;
|
81 | 83 |
$p->{BODY_PLAIN} = "plain";
|
|
84 |
$p->{BODY_PLAIN_ENCODING} = "001E";
|
82 | 85 |
$p->{BODY_HTML} = "html";
|
|
86 |
$p->{BODY_HTML_ENCODING} = "001E";
|
83 | 87 |
my $m = $p->to_email_mime;
|
84 | 88 |
ok(defined $m);
|
85 | 89 |
ok(($m->parts) == 2);
|
34 | 34 |
|
35 | 35 |
my $jpg = $parts[1];
|
36 | 36 |
like($jpg->content_type, qr{^image/jpeg}, "Content type should be image/jpeg");
|
37 | |
is($jpg->header("Content-Disposition"), "attachment; filename=test.jpg", "Testing content disposition");
|
|
37 |
like($jpg->header("Content-Disposition"), qr{^attachment; filename="?test.jpg"?$}, "Testing content disposition");
|
38 | 38 |
is(scalar($jpg->subparts), 0, "No sub-parts");
|
39 | 39 |
is(length($jpg->body), 7681, "Correct jpeg size");
|