ImageTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
  3. {
  4. function testNormal() {
  5. $this->assertResult('<img height="40" width="40" src="" alt="" />');
  6. }
  7. function testLengthTooLarge() {
  8. $this->assertResult(
  9. '<img height="40000" width="40000" src="" alt="" />',
  10. '<img height="1200" width="1200" src="" alt="" />'
  11. );
  12. }
  13. function testLengthPercentage() {
  14. $this->assertResult(
  15. '<img height="100%" width="100%" src="" alt="" />',
  16. '<img src="" alt="" />'
  17. );
  18. }
  19. function testLengthCustomMax() {
  20. $this->config->set('HTML.MaxImgLength', 20);
  21. $this->assertResult(
  22. '<img height="30" width="30" src="" alt="" />',
  23. '<img height="20" width="20" src="" alt="" />'
  24. );
  25. }
  26. function testLengthCrashFixDisabled() {
  27. $this->config->set('HTML.MaxImgLength', null);
  28. $this->assertResult(
  29. '<img height="100%" width="100%" src="" alt="" />'
  30. );
  31. $this->assertResult(
  32. '<img height="40000" width="40000" src="" alt="" />'
  33. );
  34. }
  35. function testLengthTrusted() {
  36. $this->config->set('HTML.Trusted', true);
  37. $this->assertResult(
  38. '<img height="100%" width="100%" src="" alt="" />'
  39. );
  40. $this->assertResult(
  41. '<img height="40000" width="40000" src="" alt="" />'
  42. );
  43. }
  44. }
  45. // vim: et sw=4 sts=4