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.

54 lines
2.0KB

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