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.

HTMLT.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. class HTMLPurifier_HTMLT extends HTMLPurifier_Harness
  3. {
  4. protected $path;
  5. public function __construct($path)
  6. {
  7. $this->path = $path;
  8. parent::__construct($path);
  9. }
  10. public function testHtmlt()
  11. {
  12. $parser = new HTMLPurifier_StringHashParser();
  13. $hash = $parser->parseFile($this->path); // assume parser normalizes to "\n"
  14. if (isset($hash['SKIPIF'])) {
  15. if (eval($hash['SKIPIF'])) return;
  16. }
  17. $this->config->set('Output.Newline', "\n");
  18. if (isset($hash['INI'])) {
  19. // there should be a more efficient way than writing another
  20. // ini file every time... probably means building a parser for
  21. // ini (check out the yaml implementation we saw somewhere else)
  22. $ini_file = $this->path . '.ini';
  23. file_put_contents($ini_file, $hash['INI']);
  24. $this->config->loadIni($ini_file);
  25. }
  26. $expect = isset($hash['EXPECT']) ? $hash['EXPECT'] : $hash['HTML'];
  27. $this->assertPurification(rtrim($hash['HTML']), rtrim($expect));
  28. if (isset($hash['INI'])) unlink($ini_file);
  29. }
  30. }
  31. // vim: et sw=4 sts=4