diff --git a/library/HTMLPurifier/HTML5Config.php b/library/HTMLPurifier/HTML5Config.php
index 61ef0e2..1acf344 100644
--- a/library/HTMLPurifier/HTML5Config.php
+++ b/library/HTMLPurifier/HTML5Config.php
@@ -49,6 +49,17 @@ public static function createDefault()
return $config;
}
+ /**
+ * Creates a new config object that inherits from a previous one
+ *
+ * @param HTMLPurifier_Config $config
+ * @return HTMLPurifier_Config
+ */
+ public static function inherit(HTMLPurifier_Config $config)
+ {
+ return new self($config->def, $config->plist);
+ }
+
public function getDefinition($type, $raw = false, $optimized = false)
{
// Setting HTML.* keys removes any previously instantiated HTML
diff --git a/tests/HTMLPurifier/HTML5ConfigTest.php b/tests/HTMLPurifier/HTML5ConfigTest.php
index 5cff221..3504816 100644
--- a/tests/HTMLPurifier/HTML5ConfigTest.php
+++ b/tests/HTMLPurifier/HTML5ConfigTest.php
@@ -21,4 +21,19 @@ public function testCreate()
$this->assertInstanceOf('HTMLPurifier_Config', $config4);
$this->assertEquals('iso-8859-1', $config4->get('Core.Encoding'));
}
+
+ public function testInherit()
+ {
+ $parent = HTMLPurifier_Config::create(array(
+ 'Core.Encoding' => 'iso-8859-2',
+ 'HTML.Trusted' => true,
+ ));
+
+ $config = HTMLPurifier_HTML5Config::inherit($parent);
+
+ $this->assertInstanceof('HTMLPurifier_Config', $config);
+ $this->assertSame($parent->def, $config->def);
+ $this->assertEquals('iso-8859-2', $config->get('Core.Encoding'));
+ $this->assertTrue($config->get('HTML.Trusted'));
+ }
}