Index: /CKEditor/branches/versions/3.1.x/CHANGES.html
===================================================================
--- /CKEditor/branches/versions/3.1.x/CHANGES.html	(revision 4585)
+++ /CKEditor/branches/versions/3.1.x/CHANGES.html	(revision 4586)
@@ -46,4 +46,5 @@
 		<li><a href="http://dev.fckeditor.net/ticket/4341">#4341</a> : Added the 'showborder' plugin.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/4549">#4549</a> : Make the anti-cache query string configurable.</li>
+		<li><a href="http://dev.fckeditor.net/ticket/4708">#4708</a> : Added the 'htmlEncodeOutput' config option.</li>
 	</ul>
 	<p>
Index: /CKEditor/branches/versions/3.1.x/_source/core/config.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/core/config.js	(revision 4585)
+++ /CKEditor/branches/versions/3.1.x/_source/core/config.js	(revision 4586)
@@ -283,5 +283,14 @@
 	 * config.baseFloatZIndex = 2000
 	 */
-	baseFloatZIndex : 10000
+	baseFloatZIndex : 10000,
+
+	/**
+	 * Whether escape HTML when editor update original input element.
+	 * @type {Boolean}
+	 * @default false
+	 * @example
+	 * config.htmlEncodeOutput = true;
+	 */
+	htmlEncodeOutput : false
 
 };
Index: /CKEditor/branches/versions/3.1.x/_source/core/editor.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/core/editor.js	(revision 4585)
+++ /CKEditor/branches/versions/3.1.x/_source/core/editor.js	(revision 4586)
@@ -651,8 +651,13 @@
 			if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
 			{
+				var data = this.getData();
+
+				if( this.config.htmlEncodeOutput )
+					data = CKEDITOR.tools.htmlEncode( data );
+
 				if ( element.is( 'textarea' ) )
-					element.setValue( this.getData() );
+					element.setValue( data );
 				else
-					element.setHtml( this.getData() );
+					element.setHtml( data );
 			}
 		}
