Merge branch '4.3' into 4.4
* 4.3: [Mime] Trim and remove line breaks from NamedAddress name arg
This commit is contained in:
commit
7aedfe7079
@ -39,12 +39,12 @@ final class Address
|
||||
self::$validator = new EmailValidator();
|
||||
}
|
||||
|
||||
if (!self::$validator->isValid($address, new RFCValidation())) {
|
||||
$this->address = trim($address);
|
||||
$this->name = trim(str_replace(["\n", "\r"], '', $name));
|
||||
|
||||
if (!self::$validator->isValid($this->address, new RFCValidation())) {
|
||||
throw new RfcComplianceException(sprintf('Email "%s" does not comply with addr-spec of RFC 2822.', $address));
|
||||
}
|
||||
|
||||
$this->address = $address;
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getAddress(): string
|
||||
|
@ -63,4 +63,18 @@ class AddressTest extends TestCase
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
Address::createArray([new \stdClass()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider nameEmptyDataProvider
|
||||
*/
|
||||
public function testNameEmpty(string $name)
|
||||
{
|
||||
$mail = 'mail@example.org';
|
||||
$this->assertSame($mail, (new Address($mail, $name))->toString());
|
||||
}
|
||||
|
||||
public function nameEmptyDataProvider(): array
|
||||
{
|
||||
return [[''], [' '], [" \r\n "]];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user