diff --git a/ecrire/inc/sax.php b/ecrire/inc/sax.php
index c8da1967013b0866dd4d8c5003c2e2c7d9b02fbb..93c5e2272778450d860d9bbc1686e99125f001a9 100644
--- a/ecrire/inc/sax.php
+++ b/ecrire/inc/sax.php
@@ -200,7 +200,7 @@ function inc_sax_dist($page, $apply=false)
 
 	xml_parser_free($xml_parser);
 
-	if ($res[0] == '<') return $doctype ."\n". $res;
+	if ($res[0] == '<') return trim($doctype). "\n" . $res;
 
 	$GLOBALS['xhtml_error'] = $res;
 
diff --git a/ecrire/xml/interfaces.php b/ecrire/xml/interfaces.php
index c8ac1bd0b8796b0a20b296a20d3578c395e40572..a7b4443d77213bef2db2d6f334167b84afa7c555 100644
--- a/ecrire/xml/interfaces.php
+++ b/ecrire/xml/interfaces.php
@@ -15,7 +15,7 @@ if (!defined("_ECRIRE_INC_VERSION")) return;
 include_spip('inc/sax');
 
 define('_REGEXP_DOCTYPE',
-	'/^\s*(<[?][^>]*>\s*)?<!DOCTYPE\s+(\w+)\s+(\w+)\s*([^>]*)>/');
+	'/^\s*(<[?][^>]*>\s*)?<!DOCTYPE\s+(\w+)\s+(\w+)\s*([^>]*)>\s*/');
 
 define('_SUB_REGEXP_SYMBOL', '[A-Za-z_][\w_:.-]*');