HTMLT.php 1.1 KB

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