Index: CKEditor/trunk/CHANGES.html
===================================================================
--- CKEditor/trunk/CHANGES.html	(revision 3843)
+++ CKEditor/trunk/CHANGES.html	(revision 3844)
@@ -45,4 +45,5 @@
 		Fixed issues:</p>
 	<ul>
+		<li><a href="http://dev.fckeditor.net/ticket/3869">#3869</a> : Now it is possible to insert protected source inside another one</li>
 		<li><a href="http://dev.fckeditor.net/ticket/3859">#3859</a> : Fixed Flash dialog layout in Webkit</li>
 		<li><a href="http://dev.fckeditor.net/ticket/3852">#3852</a> : Disabled textarea resizing in dialogs</li>
Index: CKEditor/trunk/_source/plugins/htmldataprocessor/plugin.js
===================================================================
--- CKEditor/trunk/_source/plugins/htmldataprocessor/plugin.js	(revision 3843)
+++ CKEditor/trunk/_source/plugins/htmldataprocessor/plugin.js	(revision 3844)
@@ -230,4 +230,6 @@
 	function protectSource( data, protectRegexes )
 	{
+		var protectedHtml = [],
+			tempRegex = /<\!--{cke_temp}(\d*?)-->/g;
 		var regexes =
 			[
@@ -249,8 +251,20 @@
 			data = data.replace( regexes[i], function( match )
 				{
-					return '<!--' + protectedSourceMarker + encodeURIComponent( match ).replace( /--/g, '%2D%2D' ) + '-->';
+					match = match.replace( tempRegex, 		// There could be protected source inside another one. (#3869).
+						function( $, id )
+						{
+							return protectedHtml[ id ];
+						}
+					);
+					return  '<!--{cke_temp}' + ( protectedHtml.push( match ) - 1 ) + '-->';
 				});
 		}
-
+		data = data.replace( tempRegex,	function( $, id )
+			{
+				return '<!--' + protectedSourceMarker + 
+						encodeURIComponent( protectedHtml[ id ] ).replace( /--/g, '%2D%2D' ) +
+						'-->';
+			}
+		);
 		return data;
 	}
Index: CKEditor/trunk/_source/tests/plugins/htmldataprocessor/htmldataprocessor.html
===================================================================
--- CKEditor/trunk/_source/tests/plugins/htmldataprocessor/htmldataprocessor.html	(revision 3843)
+++ CKEditor/trunk/_source/tests/plugins/htmldataprocessor/htmldataprocessor.html	(revision 3844)
@@ -269,4 +269,34 @@
 			assert.areSame( getTextAreaValue( '_TEXTAREA_3591_2' ),
 				dataProcessor.toDataFormat( protectedHtml ) );
+		},
+
+		test_ticket_3869_1 : function()
+		{
+			var editor = CKEDITOR.instances.editor1,
+				dataProcessor = editor.dataProcessor;
+ 
+			dataProcessor.writer = new CKEDITOR.htmlParser.basicWriter();
+			var html = getTextAreaValue( '_TEXTAREA_3869_1' );
+			var protectedHtml = dataProcessor.toHtml( html );
+
+			assert.areSame( html , dataProcessor.toDataFormat( protectedHtml ) );
+		},
+
+		test_ticket_3869_2 : 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
+			config.protectedSource.push(/<gallery[\s\S]*?<\/gallery>/gi );	// custom protected source
+			config.protectedSource.push(/<options[\s\S]*?<\/options>/gi );
+			dataProcessor.writer = new CKEDITOR.htmlParser.basicWriter();
+			var html = getTextAreaValue( '_TEXTAREA_3869_2' );
+			var protectedHtml = dataProcessor.toHtml( html );
+
+			assert.areSame( html , dataProcessor.toDataFormat( protectedHtml ) );
 		},
 
@@ -319,4 +349,28 @@
 	<textarea id="_TEXTAREA_3591"><object><param /><param /><embed></embed></object></textarea>
 	<textarea id="_TEXTAREA_3591_protected"><cke:object><cke:param></cke:param><cke:param></cke:param><cke:embed></cke:embed></cke:object></textarea>
+	<textarea id="_TEXTAREA_3869_1">#3869<script language="Javascript" type="text/javascript">
+	<!--
+		alert('-->')
+	//-->
+	</script></textarea>
+	<textarea id="_TEXTAREA_3869_2">#3869<gallery>
+	file.jpg
+	<options name="test1" value="value1"></options>
+	<options name="test2" value="value2"></options>
+	</gallery><?
+		echo '<script type="text/javascript">';
+		echo '<!--alert("-->");//-->';
+		echo '</script>';
+	?><!--<%Response.Write(now())%>//-->invalid<?
+		echo 'bbb<script>
+		<!-- 
+		ccc();<!-- </script><!-- </script>
+		//--></script>
+		<script><!-- 
+		<!-- 
+		ffff();
+		//--></script>
+		ddd';
+	?>html</textarea>
 	<textarea id="_TEXTAREA_3591_2"><object classid="clsid"><param name="movie" value="movie.swf" /><embed src="movie.swf" type="application/x-shockwave-flash"></embed></object></textarea>
 </body>
