diff --git a/library/HTMLPurifier/HTML5Config.php b/library/HTMLPurifier/HTML5Config.php index 6c55240..c518b83 100644 --- a/library/HTMLPurifier/HTML5Config.php +++ b/library/HTMLPurifier/HTML5Config.php @@ -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; } diff --git a/tests/HTMLPurifier/HTML5ConfigTest.php b/tests/HTMLPurifier/HTML5ConfigTest.php index 5239493..6735a14 100644 --- a/tests/HTMLPurifier/HTML5ConfigTest.php +++ b/tests/HTMLPurifier/HTML5ConfigTest.php @@ -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')); } }