-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: sending emails fail when comma appears in recipient name
refs #12
- Loading branch information
1 parent
43c2512
commit ec170f3
Showing
2 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
/** | ||
* conjoon | ||
* php-lib-conjoon | ||
* Copyright (C) 2019-2022 Thorsten Suckow-Homberg https://github.com/conjoon/php-lib-conjoon | ||
* Copyright (C) 2019-2023 Thorsten Suckow-Homberg https://github.com/conjoon/php-lib-conjoon | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
|
@@ -164,4 +164,41 @@ public function testCopy() | |
$this->assertSame($address1->getName(), $mailAddress->getName()); | ||
$this->assertNotSame($address1, $mailAddress); | ||
} | ||
|
||
|
||
/** | ||
* @see conjoon/php-lib-conjoon#12 | ||
*/ | ||
public function testForAddressThatNeedToBeSanitized() | ||
{ | ||
$tests = [ | ||
[ | ||
["Parker, Peter", "[email protected]"], | ||
["\"Parker, Peter\"", "[email protected]"], | ||
], | ||
[ | ||
["Parker Peter", "[email protected]"], | ||
["Parker Peter", "[email protected]"], | ||
], | ||
[ | ||
["Parker \" Peter", "[email protected]"], | ||
["\"Parker \\\" Peter\"", "[email protected]"], | ||
], | ||
[ | ||
["Parker ' Peter", "[email protected]"], | ||
["\"Parker \' Peter\"", "[email protected]"], | ||
], | ||
[ | ||
["Parker \"Parker, Peter Peter", "[email protected]"], | ||
["\"Parker \\\"Parker, Peter Peter\"", "[email protected]"], | ||
] | ||
]; | ||
|
||
foreach ($tests as $test) { | ||
[$input, $output] = $test; | ||
$mailAddress = new MailAddress($input[1], $input[0]); | ||
$this->assertSame($output[1], $mailAddress->getAddress()); | ||
$this->assertSame($output[0], $mailAddress->getName()); | ||
} | ||
} | ||
} |