NativeMailerHandlerTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /*
  3. * This file is part of the Monolog package.
  4. *
  5. * (c) Jordi Boggiano <j.boggiano@seld.be>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Monolog\Handler;
  11. use Monolog\Logger;
  12. use Monolog\TestCase;
  13. class NativeMailerHandlerTest extends TestCase
  14. {
  15. /**
  16. * @expectedException InvalidArgumentException
  17. */
  18. public function testConstructorHeaderInjection()
  19. {
  20. $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', "receiver@example.org\r\nFrom: faked@attacker.org");
  21. }
  22. /**
  23. * @expectedException InvalidArgumentException
  24. */
  25. public function testSetterHeaderInjection()
  26. {
  27. $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
  28. $mailer->addHeader("Content-Type: text/html\r\nFrom: faked@attacker.org");
  29. }
  30. /**
  31. * @expectedException InvalidArgumentException
  32. */
  33. public function testSetterArrayHeaderInjection()
  34. {
  35. $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
  36. $mailer->addHeader(array("Content-Type: text/html\r\nFrom: faked@attacker.org"));
  37. }
  38. }