mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2025-02-06 08:19:25 +03:00
fix: Validate file name length (#463)
* fix: Validate file name length $message could contain a large email text that if sent to is_file it could break with this error: ` is_file(): File name is longer than the maximum allowed path ` This validation prevents using is_file if the $message is longer than the allowed path. * style: Fix extra space * Added a small test * cs * cs
This commit is contained in:
parent
7b24312f6c
commit
07da83776a
@ -82,7 +82,7 @@ class Message extends HttpApi
|
|||||||
$params['to'] = $recipients;
|
$params['to'] = $recipients;
|
||||||
$postDataMultipart = $this->prepareMultipartParameters($params);
|
$postDataMultipart = $this->prepareMultipartParameters($params);
|
||||||
|
|
||||||
if (is_file($message)) {
|
if (strlen($message) < PHP_MAXPATHLEN && is_file($message)) {
|
||||||
$fileData = ['filePath' => $message];
|
$fileData = ['filePath' => $message];
|
||||||
} else {
|
} else {
|
||||||
$fileData = [
|
$fileData = [
|
||||||
|
@ -111,6 +111,17 @@ class MessageTest extends TestCase
|
|||||||
$api->show('url', true);
|
$api->show('url', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSendMimeWithLongMessage()
|
||||||
|
{
|
||||||
|
$api = $this->getApiMock();
|
||||||
|
$api->expects($this->once())
|
||||||
|
->method('httpPostRaw')
|
||||||
|
->willReturn(new Response());
|
||||||
|
|
||||||
|
$message = str_repeat('a', PHP_MAXPATHLEN).' and some more';
|
||||||
|
$api->sendMime('foo', ['mailbox@myapp.com'], $message, []);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user