File: 304body-postlude.t

package info (click to toggle)
libmail-message-perl 3.017-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,632 kB
  • sloc: perl: 11,156; makefile: 4
file content (82 lines) | stat: -rw-r--r-- 2,108 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env perl
# Test the processing of the prelude of multiparts
# Github issue #16

use strict;
use warnings;

use Mail::Message::Test;
use Mail::Message::Body::Multipart;

use Test::More;

# /tmp/multipart_close-delimiter_test_no-CRLF.eml.txt
# /tmp/multipart_close-delimiter_test_CRLF_empty-epilogue.eml.txt
# /tmp/multipart_close-delimiter_test_CRLF_epilogue.eml.txt
# /tmp/multipart_close-delimiter_test_CRLF_transport-padding_epilogue.eml.txt

my $message = <<'__MESSAGE';
Subject: multipart epilogue handling test
Content-Type: multipart/alternative;	boundary="_000_MW2PR1501MB2139B94F359ACBAB03EB6BA9C6629MW2PR1501MB2139_"
MIME-Version: 1.0

--_000_MW2PR1501MB2139B94F359ACBAB03EB6BA9C6629MW2PR1501MB2139_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

This is the text/plain part

--_000_MW2PR1501MB2139B94F359ACBAB03EB6BA9C6629MW2PR1501MB2139_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
</head>
<body>
This is the text/html part.
</body>
</html>

--_000_MW2PR1501MB2139B94F359ACBAB03EB6BA9C6629MW2PR1501MB2139_--
__MESSAGE

#
### No CRLF after closing boundary
#

my $msg1  = Mail::Message->read($message =~ s/[\r\n]*\z//r);
my $post1 = $msg1->body->epilogue;
ok !defined $post1, "No epilogue when no CRLF";

#
### Only CRLF after closing boundary
#

my $msg2  = Mail::Message->read($message);
my $post2 = $msg2->body->epilogue;
ok defined $post2, "Empty epilogue";
cmp_ok $post2->nrLines, '==', 0, '... is empty';

#
### A real epilogue
#

my @lines3 = ("line 1\n", "line 2\n", "line 3\n");
my $msg3   = Mail::Message->read($message . (join '', @lines3));
my $post3  = $msg3->body->epilogue;
ok defined $post3, "Filled epilogue";
cmp_ok $post3->nrLines, '==', 3, '... has content';

#
### Epilogue, blanks on boundary line
#

my $epi4   = <<'__EPILOGUE';
__EPILOGUE
my $msg4   = Mail::Message->read(($message =~ s/\n/  \n/r) . $epi4);
my $post4  = $msg4->body->epilogue;
ok defined $post4, "Epilogue with blanks on boundary line";
is $post4->string, $epi4, "... text";

done_testing;