FontFamilyTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. class HTMLPurifier_AttrDef_CSS_FontFamilyTest extends HTMLPurifier_AttrDefHarness
  3. {
  4. function test() {
  5. $this->def = new HTMLPurifier_AttrDef_CSS_FontFamily();
  6. $this->assertDef('Gill, Helvetica, sans-serif');
  7. $this->assertDef("'Times New Roman', serif");
  8. $this->assertDef("\"Times New Roman\"", "'Times New Roman'");
  9. $this->assertDef('01234');
  10. $this->assertDef(',', false);
  11. $this->assertDef('Times New Roman, serif', "'Times New Roman', serif");
  12. $this->assertDef($d = "'\xE5\xAE\x8B\xE4\xBD\x93'");
  13. $this->assertDef("\xE5\xAE\x8B\xE4\xBD\x93", $d);
  14. $this->assertDef("'\\01'", "''");
  15. $this->assertDef("'\\20'", "' '");
  16. $this->assertDef("\\0020", "' '");
  17. $this->assertDef("'\\000045'", "E");
  18. $this->assertDef("','", false);
  19. $this->assertDef("',' foobar','", "' foobar'");
  20. $this->assertDef("'\\000045a'", "Ea");
  21. $this->assertDef("'\\00045 a'", "Ea");
  22. $this->assertDef("'\\00045 a'", "'E a'");
  23. $this->assertDef("'\\\nf'", "f");
  24. // No longer supported, except maybe in NoJS mode (see source
  25. // file for more explanation)
  26. //$this->assertDef($d = '"John\'s Font"');
  27. //$this->assertDef("John's Font", $d);
  28. //$this->assertDef("'\\','f'", "\"\\5C \", f");
  29. //$this->assertDef("'\\27'", "\"'\"");
  30. //$this->assertDef('"\\22"', "\"\\22 \"");
  31. //$this->assertDef('"\\""', "\"\\22 \"");
  32. //$this->assertDef('"\'"', "\"'\"");
  33. }
  34. function testAllowed() {
  35. $this->config->set('CSS.AllowedFonts', array('serif', 'Times New Roman'));
  36. $this->assertDef('serif');
  37. $this->assertDef('sans-serif', false);
  38. $this->assertDef('serif, sans-serif', 'serif');
  39. $this->assertDef('Times New Roman', "'Times New Roman'");
  40. $this->assertDef("'Times New Roman'");
  41. $this->assertDef('foo', false);
  42. }
  43. }
  44. // vim: et sw=4 sts=4