diff --git a/library/HTMLPurifier/Config.php b/library/HTMLPurifier/Config.php
index 3184b8c9..8878684e 100644
--- a/library/HTMLPurifier/Config.php
+++ b/library/HTMLPurifier/Config.php
@@ -46,6 +46,11 @@ class HTMLPurifier_Config
*/
var $autoFinalize = true;
+ /**
+ * Instance of HTMLPurifier_Doctype, representing current doctype
+ */
+ var $doctype;
+
/**
* @param $definition HTMLPurifier_ConfigSchema that defines what directives
* are allowed.
@@ -225,6 +230,16 @@ class HTMLPurifier_Config
}
}
+ /**
+ * Returns the current doctype object
+ */
+ function getDoctype() {
+ if (!$this->doctype) {
+ $this->getHTMLDefinition();
+ }
+ return $this->doctype;
+ }
+
/**
* Loads configuration values from an ini file
* @param $filename Name of ini file
diff --git a/library/HTMLPurifier/DoctypeRegistry.php b/library/HTMLPurifier/DoctypeRegistry.php
index 34ed4736..40dc4cc3 100644
--- a/library/HTMLPurifier/DoctypeRegistry.php
+++ b/library/HTMLPurifier/DoctypeRegistry.php
@@ -93,8 +93,7 @@ class HTMLPurifier_DoctypeRegistry
function make($config) {
$original_doctype = $this->get($this->getDoctypeFromConfig($config));
$doctype = $original_doctype->copy();
- // FIXME!!! Set $doctype into $config so others can use it,
- // you might need to use two copies
+ $config->doctype = $doctype;
return $doctype;
}
diff --git a/library/HTMLPurifier/Generator.php b/library/HTMLPurifier/Generator.php
index 502be982..14b147c6 100644
--- a/library/HTMLPurifier/Generator.php
+++ b/library/HTMLPurifier/Generator.php
@@ -84,12 +84,11 @@ class HTMLPurifier_Generator
$html = '';
if (!$config) $config = HTMLPurifier_Config::createDefault();
$this->_clean_utf8 = $config->get('Output', 'EnableRedundantUTF8Cleaning');
-
- // this should replaced with a query to the Doctype object in
- // config to determine whether or not this is an XML-based language
- $this->_xhtml = $config->get('HTML', 'XHTML');
-
$this->_scriptFix = $config->get('Output', 'CommentScriptContents');
+
+ $doctype = $config->getDoctype();
+ $this->_xhtml = $doctype->xml;
+
if (!$tokens) return '';
for ($i = 0, $size = count($tokens); $i < $size; $i++) {
if ($this->_scriptFix && $tokens[$i]->name === 'script') {