Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit795dc6e

Browse files
committed
Merge branch 'hotfix/7'
Close#7
2 parents6df831d +22c9020 commit795dc6e

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ All notable changes to this project will be documented in this file, in reverse
2525
`Mime::encodeQuotedPrintable()` to ensure it never creates a header line
2626
consisting of only a dot (concatenation character), a situation that can break
2727
parsing by Outlook.
28+
-[#7](https://github.com/zendframework/zend-mime/pull/7) provides a patch that
29+
allows parsing MIME parts that have no headers.

‎src/Decode.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ public static function splitMessage($message, &$headers, &$body, $EOL = Mime::LI
105105
$message =$message->toString();
106106
}
107107
// check for valid header at first line
108-
$firstline =strtok($message,"\n");
108+
$firstlinePos =strpos($message,"\n");
109+
$firstline =$firstlinePos ===false ?$message :substr($message,0,$firstlinePos);
109110
if (!preg_match('%^[^\s]+[^:]*:%',$firstline)) {
110111
$headers = [];
111112
// TODO: we're ignoring \r for now - is this function fast enough and is it safe to assume noone needs \r?

‎test/MessageTest.php‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,41 @@ public function testDecodeMimeMessage()
112112
$this->assertEquals('12',$part2->id);
113113
}
114114

115+
/**
116+
* check if decoding a string into a \Zend\Mime\Message object works
117+
*
118+
*/
119+
publicfunctiontestDecodeMimeMessageNoHeader()
120+
{
121+
$text =<<<EOD
122+
This is a MIME-encapsulated message
123+
124+
--=_af4357ef34b786aae1491b0a2d14399f
125+
126+
The original message was received at Fri, 16 Aug 2013 00:00:48 -0700
127+
from localhost.localdomain [127.0.0.1]
128+
End content
129+
130+
--=_af4357ef34b786aae1491b0a2d14399f
131+
Content-Type: image/gif
132+
133+
This is a test
134+
--=_af4357ef34b786aae1491b0a2d14399f--
135+
EOD;
136+
$res =Mime\Message::createFromMessage($text,'=_af4357ef34b786aae1491b0a2d14399f');
137+
138+
$parts =$res->getParts();
139+
$this->assertEquals(2,count($parts));
140+
141+
$part1 =$parts[0];
142+
$part1Content =$part1->getRawContent();
143+
$this->assertContains('The original message',$part1Content);
144+
$this->assertContains('End content',$part1Content);
145+
146+
$part2 =$parts[1];
147+
$this->assertEquals('image/gif',$part2->type);
148+
}
149+
115150
publicfunctiontestNonMultipartMessageShouldNotRemovePartFromMessage()
116151
{
117152
$message =newMime\Message();// No Parts

‎test/MimeTest.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ public function testEncodeMailHeaderBase64wrap($str)
156156

157157
publicstaticfunctiondataTestEncodeMailHeaderBase64wrap()
158158
{
159-
returnarray(
160-
array("äöüäöüäöüäöüäöüäöüäöü"),
161-
array("Alle meine Entchen schwimmen in dem See, schwimmen in dem See, Köpfchen in das Wasser, Schwänzchen in die Höh!")
162-
);
159+
return[
160+
["äöüäöüäöüäöüäöüäöüäöü"],
161+
["Alle meine Entchen schwimmen in dem See, schwimmen in dem See, Köpfchen in das Wasser, Schwänzchen in die Höh!"]
162+
];
163163
}
164164

165165
publicfunctiontestFromMessageMultiPart()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp