Skip to content

Commit

Permalink
Drop PHP4 support, add PHP7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Jun 14, 2015
1 parent f037400 commit 1b6fa2d
Show file tree
Hide file tree
Showing 13 changed files with 283 additions and 362 deletions.
218 changes: 86 additions & 132 deletions Mail/mime.php

Large diffs are not rendered by default.

253 changes: 106 additions & 147 deletions Mail/mimePart.php

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions tests/encoding_case.phpt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
--TEST--
Bug #2364 Tabs in _quotedPrintableEncode()
Bug #2364 Tabs in Mail_mimePart::quotedPrintableEncode()
--SKIPIF--
--FILE--
<?php
$test = "Here's\t\na tab\n";
require_once('Mail/mimePart.php');
$part = new Mail_mimePart();
print $part->_quotedPrintableEncode($test, 7);
print Mail_mimePart::quotedPrintableEncode($test, 7);
?>
--EXPECT--
Here's=
Expand Down
22 changes: 10 additions & 12 deletions tests/test_Bug_12411.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,22 @@ Bug #12411 RFC2047 encoded attachment filenames
--FILE--
<?php
include "Mail/mime.php";
$m = new Mail_mime();
$Mime = new Mail_mime();

// some text with polish Unicode letter at the beginning
$filename = base64_decode("xZtjaWVtYQ==");
$m->addAttachment('testfile', "text/plain", $filename, FALSE,
$Mime->addAttachment('testfile', "text/plain", $filename, FALSE,
'base64', 'attachment', 'ISO-8859-1', 'pl', '',
'quoted-printable', 'base64');

$root = $m->_addMixedPart();
$enc = $m->_addAttachmentPart($root, $m->_parts[0]);
$content = $Mime->get();
$content = str_replace("\n", '', $content);

if (preg_match_all('/(name|filename)=([^\s]+)/i', $content, $matches)) {
echo implode("\n", $matches[2]);
}

echo $enc->_headers['Content-Type'];
echo "\n";
echo $enc->_headers['Content-Disposition'];
?>
--EXPECT--
text/plain; charset=ISO-8859-1;
name="=?ISO-8859-1?Q?=C5=9Bciema?="
attachment;
filename="=?ISO-8859-1?B?xZtjaWVtYQ==?=";
size=8
"=?ISO-8859-1?Q?=C5=9Bciema?="
"=?ISO-8859-1?B?xZtjaWVtYQ==?=";
19 changes: 11 additions & 8 deletions tests/test_Bug_14529.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ Bug #14529 basename() workaround
--FILE--
<?php
include "Mail/mime.php";
$m = new Mail_mime();

$Mime = new Mail_mime();
// some text with polish Unicode letter at the beginning
$filename = base64_decode("xZtjaWVtYQ==");
$m->addAttachment('testfile', "text/plain", $filename, FALSE, 'base64', 'attachment', 'ISO-8859-1');
$root = $m->_addMixedPart();
$enc = $m->_addAttachmentPart($root, $m->_parts[0]);
print_r($enc->_headers['Content-Disposition']);
$Mime->addAttachment('testfile', "text/plain", $filename, FALSE, 'base64', 'attachment', 'ISO-8859-1');

$content = $Mime->get();
$content = str_replace("\n", '', $content);

if (preg_match('/filename([^\s]+)/i', $content, $matches)) {
echo $matches[1];
}
?>
--EXPECT--
attachment;
filename*=ISO-8859-1''%C5%9Bciema;
size=8
*=ISO-8859-1''%C5%9Bciema;
17 changes: 11 additions & 6 deletions tests/test_Bug_15320.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ Bug #15320 Charset parameter in Content-Type of mail parts
--FILE--
<?php
include "Mail/mime.php";
$m = new Mail_mime();
$m->addAttachment('testfile', "text/plain", 'file.txt', FALSE, 'base64', 'attachment', 'ISO-8859-1');
$root = $m->_addMixedPart();
$enc = $m->_addAttachmentPart($root, $m->_parts[0]);
print_r($enc->_headers['Content-Type']);

$Mime = new Mail_mime();
$Mime->addAttachment('testfile', "text/plain", 'file.txt', FALSE, 'base64', 'attachment', 'ISO-8859-1');

$content = $Mime->get();
//$content = str_replace("\n", '', $content);

if (preg_match('/Content-type:([^\n]+)/i', $content, $matches)) {
echo $matches[1];
}

?>
--EXPECT--
text/plain; charset=ISO-8859-1;
name=file.txt

21 changes: 9 additions & 12 deletions tests/test_Bug_18083.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@ Bug #18083 Separate charset for attachment's content and headers
--FILE--
<?php
include "Mail/mime.php";
$m = new Mail_mime();
$Mime = new Mail_mime();

$m->addAttachment('testfile', "text/plain",
$Mime->addAttachment('testfile', "text/plain",
base64_decode("xZtjaWVtYQ=="), FALSE,
'base64', 'attachment', 'ISO-8859-1', 'pl', '',
'quoted-printable', 'base64', '', 'UTF-8');

$root = $m->_addMixedPart();
$enc = $m->_addAttachmentPart($root, $m->_parts[0]);
$content = $Mime->get();
$content = str_replace("\n", '', $content);

echo $enc->_headers['Content-Type'];
echo "\n";
echo $enc->_headers['Content-Disposition'];
if (preg_match_all('/(name|filename)=([^\s]+)/i', $content, $matches)) {
echo implode("\n", $matches[2]);
}
?>
--EXPECT--
text/plain; charset=ISO-8859-1;
name="=?UTF-8?Q?=C5=9Bciema?="
attachment;
filename="=?UTF-8?B?xZtjaWVtYQ==?=";
size=8
"=?UTF-8?Q?=C5=9Bciema?="
"=?UTF-8?B?xZtjaWVtYQ==?=";
21 changes: 9 additions & 12 deletions tests/test_Bug_19497.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ Bug #19497 Attachment filenames with a slash character
--FILE--
<?php
include "Mail/mime.php";
$m = new Mail_mime();
$Mime = new Mail_mime();

$filename = "test/file.txt";
$m->addAttachment('testfile', "text/plain", $filename, FALSE,
$Mime->addAttachment('testfile', "text/plain", $filename, FALSE,
'base64', 'attachment', 'ISO-8859-1', '', '', 'quoted-printable', 'base64');

$root = $m->_addMixedPart();
$enc = $m->_addAttachmentPart($root, $m->_parts[0]);
$content = $Mime->get();
$content = str_replace("\n", '', $content);

echo $enc->_headers['Content-Type'];
echo "\n";
echo $enc->_headers['Content-Disposition'];
if (preg_match_all('/(name|filename)=([^\s]+)/i', $content, $matches)) {
echo implode("\n", $matches[2]);
}
?>
--EXPECT--
text/plain; charset=ISO-8859-1;
name="test/file.txt"
attachment;
filename="test/file.txt";
size=8
"test/file.txt"
"test/file.txt";
20 changes: 12 additions & 8 deletions tests/test_Bug_3513_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ Bug #3513 Support of RFC2231 in header fields. (ISO-8859-1)
--SKIPIF--
--FILE--
<?php
$test = "Fóóbær.txt";
require_once('Mail/mime.php');
$Mime=new Mail_Mime();

$test = "Fóóbær.txt";
$Mime = new Mail_Mime();
$Mime->addAttachment('testfile',"text/plain", $test, FALSE, 'base64', 'attachment', 'ISO-8859-1');
$root = $Mime->_addMixedPart();
$enc = $Mime->_addAttachmentPart($root, $Mime->_parts[0]);
print($enc->_headers['Content-Disposition']);

$content = $Mime->get();
$content = str_replace("\n", '', $content);

if (preg_match('/filename([^\s]+)/i', $content, $matches)) {
echo $matches[1];
}

--EXPECT--
attachment;
filename*=ISO-8859-1''F%F3%F3b%E6r.txt;
size=8
*=ISO-8859-1''F%F3%F3b%E6r.txt;
22 changes: 13 additions & 9 deletions tests/test_Bug_3513_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ Bug #3513 Support of RFC2231 in header fields. (UTF-8)
--SKIPIF--
--FILE--
<?php
$test = "Süper gröse tolle tolle grüße.txt";
require_once('Mail/mime.php');
$Mime=new Mail_Mime();

$test = "Süper gröse tolle tolle grüße.txt";
$Mime = new Mail_Mime();
$Mime->addAttachment('testfile',"text/plain", $test, FALSE, 'base64', 'attachment', 'UTF-8', 'de');
$root = $Mime->_addMixedPart();
$enc = $Mime->_addAttachmentPart($root, $Mime->_parts[0]);
print($enc->_headers['Content-Disposition']);

$content = $Mime->get();
$content = str_replace("\n", '', $content);

if (preg_match_all('/filename([^\s]+)/i', $content, $matches)) {
echo implode("\n", $matches[1]);
}

--EXPECT--
attachment;
filename*0*=UTF-8'de'S%C3%BCper%20gr%C3%B6se%20tolle%20tolle%20gr%C3%BC;
filename*1*=%C3%9Fe.txt;
size=8
*0*=UTF-8'de'S%C3%BCper%20gr%C3%B6se%20tolle%20tolle%20gr%C3%BC;
*1*=%C3%9Fe.txt;
17 changes: 10 additions & 7 deletions tests/test_Bug_3513_3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ mb_internal_encoding('ISO-2022-JP');
$testEncoded="GyRCRnxLXDhsGyhCLnR4dA==";
$test = base64_decode($testEncoded); // Japanese filename in ISO-2022-JP charset.
require_once('Mail/mime.php');
$Mime=new Mail_Mime();

$Mime = new Mail_Mime();
$Mime->addAttachment('testfile',"text/plain", $test, FALSE, 'base64', 'attachment', 'iso-2022-jp', '');
$root = $Mime->_addMixedPart();
$enc = $Mime->_addAttachmentPart($root, $Mime->_parts[0]);
print($enc->_headers['Content-Disposition']);

$content = $Mime->get();
$content = str_replace("\n", '', $content);

if (preg_match('/filename([^\s]+)/i', $content, $matches)) {
echo $matches[1];
}
?>
--EXPECT--
attachment;
filename*=iso-2022-jp''%1B$BF|K%5C8l%1B%28B.txt;
size=8
*=iso-2022-jp''%1B$BF|K%5C8l%1B%28B.txt;

5 changes: 2 additions & 3 deletions tests/test_Bug_7561_1.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Bug #7561 Mail_mimePart::_quotedPrintableEncode() misbehavior with mbstring overload
Bug #7561 Mail_mimePart::quotedPrintableEncode() misbehavior with mbstring overload
--SKIPIF--
<?php
include "PEAR.php";
Expand All @@ -17,10 +17,9 @@ ini_set('mbstring.internal_encoding', 'UTF-8');
ini_set('mbstring.http_output', 'UTF-8');

include("Mail/mimePart.php");
$part = new Mail_mimePart('', array('eol'=>"\n"));
// string is UTF-8 encoded
$input = "Micha\xC3\xABl \xC3\x89ric St\xC3\xA9phane";
$rv = $part->_quotedPrintableEncode($input);
$rv = Mail_mimePart::quotedPrintableEncode($input, 76, "\n");
echo $rv, "\n";
--EXPECT--
Micha=C3=ABl =C3=89ric St=C3=A9phane
5 changes: 2 additions & 3 deletions tests/test_Bug_9722_1.phpt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
--TEST--
Bug #9722 _quotedPrintableEncode does not encode dot at start of line on Windows platform
Bug #9722 quotedPrintableEncode does not encode dot at start of line on Windows platform
--SKIPIF--
--FILE--
<?php
include("Mail/mimePart.php");
$part = new Mail_mimePart('', array('eol'=>"\n"));
$text = "This
is a
test
Expand All @@ -13,7 +12,7 @@ test
//really fun//
to make :(";

print_r($part->_quotedPrintableEncode($text));
print_r(Mail_mimePart::quotedPrintableEncode($text, 76, "\n"));

--EXPECT--
This
Expand Down

0 comments on commit 1b6fa2d

Please sign in to comment.