Skip to content

Commit

Permalink
Don't auto-finalize config upon creation
Browse files Browse the repository at this point in the history
  • Loading branch information
xemlock authored Feb 6, 2018
1 parent ba2f25f commit ab7dc23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion library/HTMLPurifier/HTML5Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ public static function create($config = null, HTMLPurifier_ConfigSchema $schema
}
}

$def = $configObj->getHTMLDefinition(true); // this finalizes config
// Prevent auto-finalization of config when retrieving HTML definition
$autoFinalize = $configObj->autoFinalize;
$configObj->autoFinalize = false;

$def = $configObj->getHTMLDefinition(true);
HTMLPurifier_HTML5Definition::setup($def);

$configObj->autoFinalize = $autoFinalize;

return $configObj;
}

Expand Down
5 changes: 5 additions & 0 deletions tests/HTMLPurifier/HTML5ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,10 @@ public function testCreate()
));
$this->assertInstanceOf('HTMLPurifier_Config', $config3);
$this->assertEquals('iso-8859-1', $config3->get('Core.Encoding'));

$config4 = HTMLPurifier_HTML5Config::create();
$config4->set('Core.Encoding', 'iso-8859-1');
$this->assertInstanceOf('HTMLPurifier_Config', $config4);
$this->assertEquals('iso-8859-1', $config4->get('Core.Encoding'));
}
}

0 comments on commit ab7dc23

Please sign in to comment.