SafeEmbedTest.php 1.7 KB

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