diff --git a/includes/simplenews.source.inc b/includes/simplenews.source.inc index 862865c..8a9df4b 100644 --- a/includes/simplenews.source.inc +++ b/includes/simplenews.source.inc @@ -529,17 +529,12 @@ class SimplenewsSourceNode implements SimplenewsSourceNodeInterface { * Implements SimplenewsSourceInterface::getFromFormatted(). */ function getFromFormatted() { - $name = $this->getCategory()->from_name; - - // Windows based PHP systems don't accept formatted emails. + // Windows based PHP systems don't accept formatted email addresses. if (drupal_substr(PHP_OS, 0, 3) == 'WIN') { return $this->getFromAddress(); } - else { - return '"' . $name . '" <' . $this->getFromAddress() . '>'; - } - return $formatted_address; + return '"'. addslashes(mime_header_encode($this->getCategory()->from_name)) .'" <'. $this->getFromAddress() .'>'; } /** diff --git a/tests/simplenews.test b/tests/simplenews.test index 5b14993..765f0aa 100644 --- a/tests/simplenews.test +++ b/tests/simplenews.test @@ -2613,9 +2613,11 @@ class SimplenewsSourceTestCase extends SimplenewsTestCase { // Make sure the body is only attached once. $this->assertEqual(1, preg_match_all('/Mail token/', $mail['params']['plaintext'], $matches)); - // The mail system is responsible for mime encoding, make sure the from - // address is not yet encoded. - $this->assertEqual('"' . $edit_category['from_name'] . '" <' . $edit_category['from_address'] . '>', $mail['from']); + // Make sure formatted address is properly encoded. + $from = '"' . addslashes(mime_header_encode($edit_category['from_name'])) . '" <' . $edit_category['from_address'] . '>'; + $this->assertEqual($from, $mail['from']); + // And make sure it won't get encoded twice. + $this->assertEqual($from, mime_header_encode($mail['from'])); // @todo: Improve this check, there are currently two spaces, not sure // where they are coming from.