1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Improve correctness of email address escaping in Mailgun/Postmark

Summary: Ref T13053. Uses the changes in D19026 to escape mail addresses. Those rules may not be right yet, but they're at least all in one place, have test coverage, and aren't obviously incorrect.

Test Plan: Will vet this more extensively when re-testing all mailers.

Maniphest Tasks: T13053

Differential Revision: https://secure.phabricator.com/D19027
This commit is contained in:
epriestley 2018-02-08 08:57:07 -08:00
parent 948b0ceca4
commit 942b17a980
2 changed files with 6 additions and 8 deletions

View file

@ -96,8 +96,9 @@ abstract class PhabricatorMailImplementationAdapter extends Phobject {
protected function renderAddress($email, $name = null) {
if (strlen($name)) {
// TODO: This needs to be escaped correctly.
return "{$name} <{$email}>";
return (string)id(new PhutilEmailAddress())
->setDisplayName($name)
->setAddress($email);
} else {
return $email;
}

View file

@ -21,7 +21,7 @@ final class PhabricatorMailImplementationMailgunAdapter
if (empty($this->params['reply-to'])) {
$this->params['reply-to'] = array();
}
$this->params['reply-to'][] = "{$name} <{$email}>";
$this->params['reply-to'][] = $this->renderAddress($name, $email);
return $this;
}
@ -110,11 +110,8 @@ final class PhabricatorMailImplementationMailgunAdapter
}
$from = idx($this->params, 'from');
if (idx($this->params, 'from-name')) {
$params['from'] = "\"{$this->params['from-name']}\" <{$from}>";
} else {
$params['from'] = $from;
}
$from_name = idx($this->params, 'from-name');
$params['from'] = $this->renderAddress($from, $from_name);
if (idx($this->params, 'reply-to')) {
$replyto = $this->params['reply-to'];