summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_test/tests/inc/mailer.test.php20
-rw-r--r--inc/Mailer.class.php1
2 files changed, 21 insertions, 0 deletions
diff --git a/_test/tests/inc/mailer.test.php b/_test/tests/inc/mailer.test.php
index b2c74a257..053e216b8 100644
--- a/_test/tests/inc/mailer.test.php
+++ b/_test/tests/inc/mailer.test.php
@@ -7,6 +7,14 @@ class TestMailer extends Mailer {
public function prop($name){
return $this->$name;
}
+
+ public function &propRef($name) {
+ return $this->$name;
+ }
+
+ public function prepareHeaders() {
+ return parent::prepareHeaders();
+ }
}
class mailer_test extends DokuWikiTest {
@@ -90,5 +98,17 @@ class mailer_test extends DokuWikiTest {
}
}
+ /**
+ * @see https://forum.dokuwiki.org/post/35822
+ */
+ function test_emptyBCCorCC() {
+ $mail = new TestMailer();
+ $headers = &$mail->propRef('headers');
+ $headers['Bcc'] = '';
+ $headers['Cc'] = '';
+ $header = $mail->prepareHeaders();
+ $this->assertEquals(0, preg_match('/(^|\n)Bcc: (\n|$)/', $header), 'Bcc found in headers.');
+ $this->assertEquals(0, preg_match('/(^|\n)Cc: (\n|$)/', $header), 'Bcc found in headers.');
+ }
}
//Setup VIM: ex: et ts=4 :
diff --git a/inc/Mailer.class.php b/inc/Mailer.class.php
index cbd1eb0a9..f1492be9b 100644
--- a/inc/Mailer.class.php
+++ b/inc/Mailer.class.php
@@ -555,6 +555,7 @@ class Mailer {
protected function prepareHeaders() {
$headers = '';
foreach($this->headers as $key => $val) {
+ if ($val === '') continue;
$headers .= "$key: $val".MAILHEADER_EOL;
}
return $headers;