-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: binary files as part are corrupted when stripping carriage returns #26
base: 2.9.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -246,7 +246,7 @@ public static function dataTestFromMessageDecode(): array | |
'Alle meine Entchen schwimmen in dem See, schwimmen in dem See, K=C3=B6pfche= | ||
n in das Wasser, Schw=C3=A4nzchen in die H=C3=B6h!', | ||
], | ||
['foobar', 'base64', 'Zm9vYmFyCg=='], | ||
['foobar', 'base64', 'Zm9vYmFy'], | ||
Ocramius marked this conversation as resolved.
Show resolved
Hide resolved
|
||
]; | ||
// phpcs:enable | ||
} | ||
|
@@ -257,15 +257,15 @@ public static function dataTestFromMessageDecode(): array | |
public function testFromMessageDecode(string $input, string $encoding, string $result): void | ||
{ | ||
$parts = Mime\Message::createFromMessage( | ||
'--089e0141a1902f83ee04e0a07b7a' . "\r\n" | ||
. 'Content-Type: text/plain; charset=UTF-8' . "\r\n" | ||
. 'Content-Transfer-Encoding: ' . $encoding . "\r\n" | ||
. "\r\n" | ||
. $result . "\r\n" | ||
'--089e0141a1902f83ee04e0a07b7a' . "\n" | ||
. 'Content-Type: text/plain; charset=UTF-8' . "\n" | ||
. 'Content-Transfer-Encoding: ' . $encoding . "\n" | ||
. "\n" | ||
. $result . "\n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above: changes to pre-existing test probably hiding a BC break 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand your concern, but don't have a clear answer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TBH, if that's how things are, that would be an https://xkcd.com/1172/ :D I just want a second review by somebody else, but if it's really like that, the bugfix is valid, and to be merged with the test changes too 👍 |
||
. '--089e0141a1902f83ee04e0a07b7a--', | ||
'089e0141a1902f83ee04e0a07b7a' | ||
)->getParts(); | ||
$this->assertSame($input . "\n", $parts[0]->getRawContent()); | ||
$this->assertSame($input, $parts[0]->getRawContent()); | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,4 +205,20 @@ public function testSetContentRaisesInvalidArgumentExceptionForInvalidContentTyp | |
$this->expectException(Mime\Exception\InvalidArgumentException::class); | ||
$part->setContent($content); | ||
} | ||
|
||
public function testBinaryPart() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Give this a better name: |
||
{ | ||
$content = file_get_contents(__DIR__ . '/TestAsset/laminas.png'); | ||
$inputMessage = new Mime\Message(); | ||
$inputMessage->addPart(new Mime\Part('Hello World')); | ||
$inputMessage->addPart(new Mime\Part($content)); | ||
|
||
$outputMessage = Mime\Message::createFromMessage( | ||
$inputMessage->generateMessage(), | ||
$inputMessage->getMime()->boundary() | ||
); | ||
$parts = $outputMessage->getParts(); | ||
$this->assertCount(2, $parts); | ||
$this->assertEquals($content, $parts[1]->getContent()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does
$matches[0][1]
represent? Can you memoize it into a variable with a descriptive name, please?