File: 502parser-nested.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 (92 lines) | stat: -rw-r--r-- 2,339 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
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env perl
# Test processing a message/rfc822, in unpacked form

use strict;
use warnings;

use Mail::Message::Test;
use Mail::Message;

use Test::More tests => 2;
use IO::Scalar;

#
# Reading a very complicate message from scalar
#

my $msg = Mail::Message->read(<<'END-OF-MESSAGE', strip_status_fields => 0);
From: "you" <You@your.place>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="3/Cnt5Mj2+"
Content-Transfer-Encoding: 7bit
Message-ID: <15375.28519.265629.832146@tradef1-fe>
Date: Thu, 6 Dec 2001 14:15:19 +0100 (MET)
To: me@example.com
Subject: forwarded message from Pietje Puk
Status: RO

--3/Cnt5Mj2+
Content-Type: text/plain; charset=us-ascii
Content-Description: message body text
Content-Transfer-Encoding: 7bit

This is some text before a forwarded multipart!!

--3/Cnt5Mj2+
Content-Type: message/rfc822
Content-Description: forwarded message

MIME-Version: 1.0
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_0017_01C17E5E.A5657580"
Message-ID: <001a01c17e56$5fc02640$5f23643e@ibm5522ccd>
From: "Someone" <tux@fish.aq>
To: "Me" <me@example.com>
Subject: A multipart alternative

This is a multi-part message in MIME format.

------=_NextPart_000_0017_01C17E5E.A5657580
CONTENT-TRANSFER-ENCODING: quoted-printable
Content-Type: text/plain;
	charset="iso-8859-1"

Send me a postcard if you read this.
Oh, another line.

------=_NextPart_000_0017_01C17E5E.A5657580
CONTENT-TRANSFER-ENCODING: quoted-printable
Content-Type: text/html;
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
</HEAD>
<BODY bgColor=3D#ffffff>
Send me a postcard if you read this.<BR>
Oh, another line.<BR>
</BODY></HTML>

------=_NextPart_000_0017_01C17E5E.A5657580--

--3/Cnt5Mj2+--
END-OF-MESSAGE

ok(defined $msg);

my $dump;
my $catch   = IO::Scalar->new(\$dump);
$msg->printStructure($catch);

# if 1550 bytes is reported for the whole message, then the Status
# field hasn't been removed after reading.
is($dump, <<'DUMP');
multipart/mixed: forwarded message from Pietje Puk (1519 bytes)
   text/plain (164 bytes)
   message/rfc822 (1012 bytes)
      multipart/alternative: A multipart alternative (943 bytes)
         text/plain (148 bytes)
         text/html (358 bytes)
DUMP