Okay, what I experience is that - since you wrap the markup in a CDATA section - we stay "hands off" and let it pass through our rendering engine untouched.
Since you pass in a complete xhtml document (with head, body etc) we emit that "as is" at the place where you put your function.
I don't experience fragments from the CDATA declaration left behind, like you do though - but I would expect this could happen if your data also have a nested CDATA section. CDATA sectons within CDATA sections would create an odd situations, since the 'end marker' from the inner sections will be picked up by the parser.
I do experience "view source" in Firefox fail showing the html source in a correct way - perhaps this is what you see? Using the source viewer inside the C1 Console browser shows the entire document just fine (and show the nested document).
Anyway - I cannot see a bug here in either 4.1 or 4.2 - things are working as designed with my repro below: Since we wrap markup in a CDATA we tread it as "hands off" and we don't do the html/head/body merging we would normally do.
My suggestion is that you don't use CDATA sections - and if you need it, you apply this around the specific unsafe zones you have, not around entire documents.
Below is my repro which will send the xhtml document untouched - if you can tweak it into something that provoke a bug, that would be very helpful.
Since you pass in a complete xhtml document (with head, body etc) we emit that "as is" at the place where you put your function.
I don't experience fragments from the CDATA declaration left behind, like you do though - but I would expect this could happen if your data also have a nested CDATA section. CDATA sectons within CDATA sections would create an odd situations, since the 'end marker' from the inner sections will be picked up by the parser.
I do experience "view source" in Firefox fail showing the html source in a correct way - perhaps this is what you see? Using the source viewer inside the C1 Console browser shows the entire document just fine (and show the nested document).
Anyway - I cannot see a bug here in either 4.1 or 4.2 - things are working as designed with my repro below: Since we wrap markup in a CDATA we tread it as "hands off" and we don't do the html/head/body merging we would normally do.
My suggestion is that you don't use CDATA sections - and if you need it, you apply this around the specific unsafe zones you have, not around entire documents.
Below is my repro which will send the xhtml document untouched - if you can tweak it into something that provoke a bug, that would be very helpful.
@inherits RazorFunction
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
<div>
@{
var html = XhtmlDocument.Parse("<html xmlns='http://www.w3.org/1999/xhtml'>
	<head></head>
	<body>

Het Cubs jeugdteam van Leidse Rugbyclub DIOK mag zich sinds afgelopen zaterdag kampioen van Nederland noemen. In een zinderende finale versloegen zij het combinatieteam van BSN/Bassets met 17-12.

	</body>
</html>");
}
<![CDATA[
@Html.Raw(html.ToString())
]]>
</div>
</body>
</html>