Skip to content

Commit f4cbca9

Browse files
Merge branch '4.3' into 4.4
* 4.3: [Mailer] Remove line breaks in email attachment content Update links to documentation [Validator] Add the missing translations for the Arabic (ar) locale ensure to expect no validation for the right reasons [PhpUnitBridge] Add test case for @expectedDeprecation annotation [PhpUnitBridge][SymfonyTestsListenerTrait] Remove $testsWithWarnings stack [Mailer][MailchimpBridge] Fix missing attachments when sending via Mandrill API [Mailer][MailchimpBridge] Fix incorrect sender address when sender has name [HttpClient] fix capturing SSL certificates with NativeHttpClient [TwigBridge][Form] Added missing help messages in form themes Update year in license files Update year in license files [HttpClient] fix typo [Console][FormatterHelper] Use helper strlen statically and remove duplicated code [Routing] Fix i18n routing when the url contains the locale Fix BC issue in phpDoc Reflection library [Translator] Performance improvement in MessageCatalogue and catalogue operations.
2 parents 3c3b023 + 4b19c6e commit f4cbca9

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019 Fabien Potencier
1+
Copyright (c) 2019-2020 Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

Tests/Transport/SendgridApiTransportTest.php

+52
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,56 @@ public function testSend()
9797
$mailer = new SendgridApiTransport('foo', $httpClient);
9898
$mailer->send($email);
9999
}
100+
101+
public function testLineBreaksInEncodedAttachment()
102+
{
103+
$email = new Email();
104+
$email->from('[email protected]')
105+
106+
// even if content doesn't include new lines, the base64 encoding performed later may add them
107+
->attach('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod', 'lorem.txt');
108+
109+
$response = $this->createMock(ResponseInterface::class);
110+
111+
$response
112+
->expects($this->once())
113+
->method('getStatusCode')
114+
->willReturn(202);
115+
$response
116+
->expects($this->once())
117+
->method('getHeaders')
118+
->willReturn(['x-message-id' => '1']);
119+
120+
$httpClient = $this->createMock(HttpClientInterface::class);
121+
122+
$httpClient
123+
->expects($this->once())
124+
->method('request')
125+
->with('POST', 'https://api.sendgrid.com/v3/mail/send', [
126+
'json' => [
127+
'personalizations' => [
128+
[
129+
'to' => [['email' => '[email protected]']],
130+
'subject' => null,
131+
],
132+
],
133+
'from' => ['email' => '[email protected]'],
134+
'content' => [],
135+
'attachments' => [
136+
[
137+
'content' => 'TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdCwgc2VkIGRvIGVpdXNtb2Q=',
138+
'filename' => 'lorem.txt',
139+
'type' => 'application/octet-stream',
140+
'disposition' => 'attachment',
141+
],
142+
],
143+
],
144+
'auth_bearer' => 'foo',
145+
])
146+
->willReturn($response);
147+
148+
$mailer = new SendgridApiTransport('foo', $httpClient);
149+
150+
$mailer->send($email);
151+
}
100152
}

Transport/SendgridApiTransport.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private function getAttachments(Email $email): array
132132
$disposition = $headers->getHeaderBody('Content-Disposition');
133133

134134
$att = [
135-
'content' => $attachment->bodyToString(),
135+
'content' => str_replace("\r\n", '', $attachment->bodyToString()),
136136
'type' => $headers->get('Content-Type')->getBody(),
137137
'filename' => $filename,
138138
'disposition' => $disposition,

0 commit comments

Comments
 (0)