﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
12353	Markup inserted prior to doctype not handled nicely.	Marcus Bointon		"Any HTML markup inserted before a `doctype` or `<html>` tag is clearly invalid, but the way that CKEditor handles it isn't helpful. Given a doc that starts like this (adapted from your [http://ckeditor.com/demo#full-page full-page demo page]):

{{{
<p>hello</p>
<html>
<head>
	<title>CKEditor Full Page Example</title>
</head>
<body>
<h1><img alt=""Saturn V carrying Apollo 11"" class=""right"" src=""http://c.cksource.com/a/1/img/sample.jpg"" /> Apollo 11</h1>
...
}}}

It is transformed into this:

{{{
<html>
<head>
</head>
<body>
<p>hello</p>
</body>
</html>
<title>CKEditor Full Page Example</title>
<h1><img alt=""Saturn V carrying Apollo 11"" class=""right"" src=""http://c.cksource.com/a/1/img/sample.jpg"" /> Apollo 11</h1>
}}}

If you pass this into any HTML sanitisation system (such as htmlpurifier), it will probably strip everything after the closing `</html>` (trashing nearly all of the document, including all of the original `head` tag), and renderers may ignore anything after the `</html>`, though I note that CKEditor does not. I understand the reasoning behind this approach, but it is unlikely that is what the user intended, and it would be better to try something a little more sane first, for example, if there is a `<body>` tag, move the early markup after that, so the output would become:

{{{
<html>
<head>
	<title>CKEditor Full Page Example</title>
</head>
<body>
<p>hello</p>
<h1><img alt=""Saturn V carrying Apollo 11"" class=""right"" src=""http://c.cksource.com/a/1/img/sample.jpg"" /> Apollo 11</h1>
...
}}}

If that fails, //then// fall back to wrapping it in an HTML element. As it stands, moving all the content to after the `</html>` tag is far more destructive than having content before the `<html>` tag in the first place!"	Bug	confirmed	Normal		General	4.0			
