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.

62 lines
1.5KB

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