xref: /PHP-7.3/ext/imap/tests/bug35669.phpt (revision 782352c5)
1--TEST--
2Bug #35669 (imap_mail_compose() crashes with multipart-multiboundary-email)
3--SKIPIF--
4<?php
5        if (!extension_loaded("imap")) {
6                die("skip imap extension not available");
7        }
8?>
9--FILE--
10<?php
11	$envelope["from"] = 'Santa <somewhere@northpole.gov>';
12        $envelope["to"]  = 'The bad smurf <bad@smurf.com>';
13        $envelope['date'] = 'Wed, 04 Jan 2006 19:24:43 -0500';
14
15        $multipart["type"] = TYPEMULTIPART;
16        $multipart["subtype"] = "MIXED";
17        $body[] = $multipart; //add multipart stuff
18
19        $textpart["type"] = TYPEMULTIPART;
20        $textpart["subtype"] = "ALTERNATIVE";
21        $body[] = $textpart; //add body part
22
23        $plain["type"] = TYPETEXT;
24        $plain["subtype"] = "PLAIN";
25        $plain["charset"] = "iso-8859-1";
26        $plain["encoding"] = ENCQUOTEDPRINTABLE;
27        $plain["description"] = "Plaintype part of message";
28        $plain['disposition'] = "inline";
29        $plain["contents.data"] = 'See mom, it will crash';
30
31        $body[] = $plain; //next add plain text part
32
33        $html["type"] = TYPETEXT;
34        $html["subtype"] = "HTML";
35        $html["charset"] = "iso-8859-1";
36        $html["encoding"] = ENCQUOTEDPRINTABLE;
37        $html["description"] = "HTML part of message";
38        $html['disposition'] = "inline";
39        $html["contents.data"] = 'See mom, it will <b>crash</b>';
40
41        $body[] = $html;
42
43        echo imap_mail_compose($envelope, $body);
44?>
45--EXPECTF--
46Date: Wed, 04 Jan 2006 19:24:43 -0500
47From: Santa <somewhere@northpole.gov>
48To: The bad smurf <bad@smurf.com>
49MIME-Version: 1.0
50Content-Type: MULTIPART/MIXED; BOUNDARY="%s"
51
52--%s
53Content-Type: TEXT/ALTERNATIVE; CHARSET=US-ASCII
54
55
56--%s
57Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1
58Content-Transfer-Encoding: QUOTED-PRINTABLE
59Content-Description: Plaintype part of message
60
61See mom, it will crash
62--%s
63Content-Type: TEXT/HTML; CHARSET=iso-8859-1
64Content-Transfer-Encoding: QUOTED-PRINTABLE
65Content-Description: HTML part of message
66
67See mom, it will <b>crash</b>
68--%s--
69