You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.7KB

  1. <?php
  2. class HTMLPurifier_HTMLModule_SafeEmbedTest extends HTMLPurifier_HTMLModuleHarness
  3. {
  4. public function setUp()
  5. {
  6. parent::setUp();
  7. $def = $this->config->getHTMLDefinition(true);
  8. $def->manager->addModule('SafeEmbed');
  9. }
  10. public function testMinimal()
  11. {
  12. $this->assertResult(
  13. '<embed src="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" />',
  14. '<embed src="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" allowscriptaccess="never" allownetworking="internal" type="application/x-shockwave-flash" />'
  15. );
  16. }
  17. public function testYouTube()
  18. {
  19. $this->assertResult(
  20. '<embed src="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed>',
  21. '<embed src="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="never" allownetworking="internal" />'
  22. );
  23. }
  24. public function testMalicious()
  25. {
  26. $this->assertResult(
  27. '<embed src="http://example.com/bad.swf" type="application/x-shockwave-flash" width="9999999" height="3499994" allowscriptaccess="always" allownetworking="always" />',
  28. '<embed src="http://example.com/bad.swf" type="application/x-shockwave-flash" width="1200" height="1200" allowscriptaccess="never" allownetworking="internal" />'
  29. );
  30. }
  31. public function testFull()
  32. {
  33. $this->assertResult(
  34. '<b><embed src="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" type="application/x-shockwave-flash" width="24" height="23" allowscriptaccess="never" allownetworking="internal" wmode="window" /></b>'
  35. );
  36. }
  37. }
  38. // vim: et sw=4 sts=4