Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/PHPMailer/PHPMailer
Browse files Browse the repository at this point in the history
  • Loading branch information
jimjag committed Nov 12, 2018
2 parents cf58579 + 04723d0 commit 2e1a669
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/SMTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public function data($msg_data)
public function hello($host = '')
{
//Try extended hello first (RFC 2821)
return (bool) ($this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host));
return $this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host);
}

/**
Expand Down
33 changes: 9 additions & 24 deletions test/PHPMailerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -997,10 +997,7 @@ public function testHtmlIso8859()
realpath($this->INCLUDE_DIR . '/examples')
);
$this->buildBody();
$this->assertTrue(
strpos($this->Mail->Body, $check) !== false,
'ISO message body does not contain expected text'
);
$this->assertContains($check, $this->Mail->Body, 'ISO message body does not contain expected text');
$this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
}

Expand Down Expand Up @@ -1121,35 +1118,23 @@ function ($html) {

//Test that local paths without a basedir are ignored
$this->Mail->msgHTML('<img src="/etc/hostname">test');
$this->assertTrue(strpos($this->Mail->Body, 'src="/etc/hostname"') !== false);
$this->assertContains('src="/etc/hostname"', $this->Mail->Body);
//Test that local paths with a basedir are not ignored
$this->Mail->msgHTML('<img src="composer.json">test', realpath($this->INCLUDE_DIR));
$this->assertTrue(strpos($this->Mail->Body, 'src="composer.json"') === false);
$this->assertNotContains('src="composer.json"', $this->Mail->Body);
//Test that local paths with parent traversal are ignored
$this->Mail->msgHTML('<img src="../composer.json">test', realpath($this->INCLUDE_DIR));
$this->assertTrue(strpos($this->Mail->Body, 'src="composer.json"') === false);
$this->assertNotContains('src="composer.json"', $this->Mail->Body);
//Test that existing embedded URLs are ignored
$this->Mail->msgHTML('<img src="cid:5d41402abc4b2a76b9719d911017c592">test');
$this->assertTrue(
strpos($this->Mail->Body, 'src="cid:5d41402abc4b2a76b9719d911017c592"') !== false
);
$this->assertContains('src="cid:5d41402abc4b2a76b9719d911017c592"', $this->Mail->Body);
//Test that absolute URLs are ignored
$this->Mail->msgHTML('<img src="https://github.com/PHPMailer/PHPMailer/blob/master/composer.json">test');
$this->assertTrue(
false !== strpos(
$this->Mail->Body,
'src="https://github.com/PHPMailer/PHPMailer/blob/master/composer.json"'
)
);
$this->assertContains('src="https://github.com/PHPMailer/PHPMailer/blob/master/composer.json"', $this->Mail->Body);
//Test that absolute URLs with anonymous/relative protocol are ignored
//Note that such URLs will not work in email anyway because they have no protocol to be relative to
$this->Mail->msgHTML('<img src="//github.com/PHPMailer/PHPMailer/blob/master/composer.json">test');
$this->assertTrue(
strpos(
$this->Mail->Body,
'src="//github.com/PHPMailer/PHPMailer/blob/master/composer.json"'
) !== false
);
$this->assertContains('src="//github.com/PHPMailer/PHPMailer/blob/master/composer.json"', $this->Mail->Body);
}

/**
Expand Down Expand Up @@ -1700,7 +1685,7 @@ public function testAddressEscaping()
$this->buildBody();
$this->Mail->preSend();
$b = $this->Mail->getSentMIMEMessage();
$this->assertTrue((false !== strpos($b, 'To: "Tim \"The Book\" O\'Reilly" <[email protected]>')));
$this->assertContains('To: "Tim \"The Book\" O\'Reilly" <[email protected]>', $b);

$this->Mail->Subject .= ': Address escaping invalid';
$this->Mail->clearAddresses();
Expand Down Expand Up @@ -1746,7 +1731,7 @@ public function testBCCAddressing()
$this->Mail->preSend();
$b = $this->Mail->getSentMIMEMessage();
$this->assertTrue($this->Mail->addBCC('[email protected]'), 'BCC addressing failed');
$this->assertTrue((false !== strpos($b, 'To: Foo <[email protected]>')));
$this->assertContains('To: Foo <[email protected]>', $b);
$this->assertTrue($this->Mail->send(), 'send failed');
}

Expand Down

0 comments on commit 2e1a669

Please sign in to comment.