diff --git a/src/Traffic/Message/Smtp.php b/src/Traffic/Message/Smtp.php index 0174cb6..0f74383 100644 --- a/src/Traffic/Message/Smtp.php +++ b/src/Traffic/Message/Smtp.php @@ -191,7 +191,7 @@ private function parseContact(string $line): Contact { if (\preg_match('/^\s*(?.*)\s*<(?.*)>\s*$/', $line, $matches) === 1) { return new Contact( - $matches['name'] ? \trim($matches['name'], ' "') : null, + $matches['name'] ? \trim(\trim($matches['name']), '"') : null, $matches['email'] ? \trim($matches['email']) : null, ); } diff --git a/tests/Unit/Traffic/Message/SmtpTest.php b/tests/Unit/Traffic/Message/SmtpTest.php index fb57bf8..7afcfce 100644 --- a/tests/Unit/Traffic/Message/SmtpTest.php +++ b/tests/Unit/Traffic/Message/SmtpTest.php @@ -43,6 +43,13 @@ public static function dataTo(): iterable new Smtp\Contact('Mary Smith: Personal Account', 'smith@home.example'), ], ]; + + yield [ + ['" Mary Smith: Personal Account " '], + [ + new Smtp\Contact(' Mary Smith: Personal Account ', 'smith@home.example'), + ], + ]; } /**