Index: /CKEditor/trunk/_source/core/config.js
===================================================================
--- /CKEditor/trunk/_source/core/config.js	(revision 3734)
+++ /CKEditor/trunk/_source/core/config.js	(revision 3735)
@@ -171,4 +171,15 @@
 	 */
 	removePlugins : '',
+	
+	/**
+	 * List of regular expressions to be executed over the input HTML,
+	 * indicating code that must stay untouched.
+	 * @type Array
+	 * @example
+	 * config.protectedSource.push( /<\?[\s\S]*?\?>/g );   // PHP Code 
+	 * config.protectedSource.push( /<%[\s\S]*?%>/g );   // ASP Code 
+	 * config.protectedSource.push( /(<asp:[^\>]+>[\s|\S]*?<\/asp:[^\>]+>)|(<asp:[^\>]+\/>)/gi );   // ASP.Net Code 
+	 */
+	protectedSource : [],
 
 	/**
Index: /CKEditor/trunk/_source/core/htmlparser/comment.js
===================================================================
--- /CKEditor/trunk/_source/core/htmlparser/comment.js	(revision 3734)
+++ /CKEditor/trunk/_source/core/htmlparser/comment.js	(revision 3735)
@@ -43,6 +43,15 @@
 		var comment = this.value;
 
-		if ( filter && !( comment = filter.onComment( comment ) ) )
-			return;
+		if ( filter )
+		{
+			if ( !( comment = filter.onComment( comment ) ) )
+				return;
+			
+			if ( typeof comment != 'string' )
+			{
+				comment.writeHtml( writer, filter );
+				return;
+			}
+		}
 
 		writer.comment( comment );
Index: /CKEditor/trunk/_source/plugins/htmldataprocessor/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/htmldataprocessor/plugin.js	(revision 3734)
+++ /CKEditor/trunk/_source/plugins/htmldataprocessor/plugin.js	(revision 3735)
@@ -8,4 +8,6 @@
 	// Regex to scan for &nbsp; at the end of blocks, which are actually placeholders.
 	var tailNbspRegex = /^[\t\r\n ]*&nbsp;$/;
+
+	var protectedSourceMarker = '{cke_protected}';
 
 	function trimFillers( block, fromSource )
@@ -169,4 +171,12 @@
 					return CKEDITOR.tools.ltrim( value.replace( /(?:^|\s+)cke_[^\s]*/g, '' ) ) || false;
 				}
+			},
+
+			comment : function( contents )
+			{
+				if ( contents.substr( 0, protectedSourceMarker.length ) == protectedSourceMarker )
+					return new CKEDITOR.htmlParser.cdata( decodeURIComponent( contents.substr( protectedSourceMarker.length ) ) );
+
+				return contents;
 			}
 		};
@@ -217,4 +227,32 @@
 	}
 
+	function protectSource( data, protectRegexes )
+	{
+		var regexes =
+			[
+				// First of any other protection, we must protect all comments
+				// to avoid loosing them (of course, IE related).
+				/<!--[\s\S]*?-->/g,
+
+				// Script tags will also be forced to be protected, otherwise
+				// IE will execute them.
+				/<script[\s\S]*?<\/script>/gi,
+
+				// <noscript> tags (get lost in IE and messed up in FF).
+				/<noscript[\s\S]*?<\/noscript>/gi
+			]
+			.concat( protectRegexes );
+		
+		for ( var i = 0 ; i < regexes.length ; i++ )
+		{
+			data = data.replace( regexes[i], function( match )
+				{
+					return '<!--' + protectedSourceMarker + encodeURIComponent( match ).replace( /--/g, '%2D%2D' ) + '-->';
+				});
+		}
+		
+		return data;
+	}
+
 	CKEDITOR.plugins.add( 'htmldataprocessor',
 	{
@@ -223,5 +261,5 @@
 		init : function( editor )
 		{
-			var dataProcessor = editor.dataProcessor = new CKEDITOR.htmlDataProcessor();
+			var dataProcessor = editor.dataProcessor = new CKEDITOR.htmlDataProcessor( editor );
 
 			dataProcessor.writer.forceSimpleAmpersand = editor.config.forceSimpleAmpersand;
@@ -234,6 +272,8 @@
 	});
 
-	CKEDITOR.htmlDataProcessor = function()
-	{
+	CKEDITOR.htmlDataProcessor = function( editor )
+	{
+		this.editor = editor;
+
 		this.writer = new CKEDITOR.htmlWriter();
 		this.dataFilter = new CKEDITOR.htmlParser.filter();
@@ -247,4 +287,6 @@
 			// The source data is already HTML, but we need to clean
 			// it up and apply the filter.
+
+			data = protectSource( data, this.editor.config.protectedSource );
 
 			// Before anything, we must protect the URL attributes as the
Index: /CKEditor/trunk/_source/tests/plugins/htmldataprocessor/htmldataprocessor.html
===================================================================
--- /CKEditor/trunk/_source/tests/plugins/htmldataprocessor/htmldataprocessor.html	(revision 3734)
+++ /CKEditor/trunk/_source/tests/plugins/htmldataprocessor/htmldataprocessor.html	(revision 3735)
@@ -22,4 +22,5 @@
 	// Local references.
 	var assert = CKEDITOR.test.assert;
+	var doc = new CKEDITOR.dom.document( document );
 
 	// In these tests, we may "reset" the writer rules to avoid it formatting
@@ -33,4 +34,13 @@
 	};
 
+	/**
+	 * IE always returning CRLF for linefeed, so remove it when retrieve pre-formated text from text area.
+	 * @param {Object} id
+	 */
+	function getTextAreaValue( id )
+	{
+		return CKEDITOR.document.getById( id ).getValue().replace(/\r/gi,'');
+	}
+
 	// These tests go far beyond the strict htmlDataProcessor code testing. We
 	// are actually testing the entire parsing system here. The combination of
@@ -218,13 +228,24 @@
 		},
 
+		test_ticket_3407 : function()
+		{
+			var editor = CKEDITOR.instances.editor1,
+				dataProcessor = editor.dataProcessor,
+				config = editor.config;
+
+			config.protectedSource.push( /<\?[\s\S]*?\?>/g );   // PHP Code
+			config.protectedSource.push( /<%[\s\S]*?%>/g );   // ASP Code
+			config.protectedSource.push( /(<asp:[^\>]+>[\s|\S]*?<\/asp:[^\>]+>)|(<asp:[^\>]+\/>)/gi );   // ASP.Net Code
+			dataProcessor.writer = new CKEDITOR.htmlParser.basicWriter();
+			var html = getTextAreaValue( '_TEXTAREA1' );
+			var protectedHtml = dataProcessor.toHtml( html );
+			assert.areSame( html , dataProcessor.toDataFormat( protectedHtml ) );
+		},
+
 		name : document.title
 	};
 })() );
 
-//window.onload = function()
-//{
-//	testCase.test_toDataFormat_ticket_3036();
-//}
-
+//window.onload = testCase.test_ticket_3407;
 	//]]>
 	</script>
@@ -232,4 +253,10 @@
 <body>
 	<textarea id="editor1" class="ckeditor" cols="80" rows="10"></textarea>
+	<textarea id="_TEXTAREA1"><script type="text/javascript">alert('>');</script><table><tbody><tr><!--- IE doesn't handle this comment ---><!--[if gte IE 6 ]>
+	<![if lt IE 8 ]>
+	gIE conditional comments
+<![endif]>
+<![endif]--><td><%Response.Write(now())%></td><td><asp:control_name id="some_id" runat="server"/></td><td><?php
+include ("head.html"); ?></td></tr></tbody></table><noscript>Your browser doesn't support JavaScript</noscript></textarea>
 </body>
 </html>
