Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 5952)
+++ /CKEditor/trunk/CHANGES.html	(revision 5953)
@@ -132,4 +132,5 @@
 		<li><a href="http://dev.ckeditor.com/ticket/5839">#5839</a> : "Insert row after" was removing the ids of the elements from the clicked row.</li>
 		<li><a href="http://dev.ckeditor.com/ticket/6315">#6315</a> : DIV plugin TT #2885 regression.</li>
+		<li><a href="http://dev.ckeditor.com/ticket/5595">#5595</a> : Extra leading spaces added in preformatted block.</li>
 		<li>Updated the following language files:<ul>
 			<li><a href="http://dev.ckeditor.com/ticket/6246">#6246</a> : Chinese Simplified;</li>
Index: /CKEditor/trunk/_source/plugins/htmldataprocessor/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/htmldataprocessor/plugin.js	(revision 5952)
+++ /CKEditor/trunk/_source/plugins/htmldataprocessor/plugin.js	(revision 5953)
@@ -316,4 +316,9 @@
 	{
 		return html.replace( protectSelfClosingRegex, '<cke:$1$2></cke:$1>' );
+	}
+
+	function protectPreFormatted( html )
+	{
+		return html.replace( /(<pre\b[^>]*>)(\r\n|\n)/g, '$1$2$2' );
 	}
 
@@ -437,4 +442,8 @@
 			// protecting them into open-close. (#3591)
 			data = protectSelfClosingElements( data );
+
+			// Compensate one leading line break after <pre> open as browsers
+			// eat it up. (#5789)
+			data = protectPreFormatted( data );
 
 			// Call the browser to help us fixing a possibly invalid HTML
Index: /CKEditor/trunk/_source/plugins/htmlwriter/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/htmlwriter/plugin.js	(revision 5952)
+++ /CKEditor/trunk/_source/plugins/htmlwriter/plugin.js	(revision 5953)
@@ -64,4 +64,6 @@
 		this._.indent = 0;
 		this._.indentation = '';
+		// Indicate preformatted block context status. (#5789)
+		this._.inPre = 0;
 		this._.rules = {};
 
@@ -159,4 +161,5 @@
 			if ( rules && rules.breakAfterOpen )
 				this.lineBreak();
+			tagName == 'pre' && ( this._.inPre = 1 );
 		},
 
@@ -207,4 +210,5 @@
 
 			this._.output.push( '</', tagName, '>' );
+			tagName == 'pre' && ( this._.inPre = 0 );
 
 			if ( rules && rules.breakAfterClose )
@@ -224,5 +228,5 @@
 			{
 				this.indentation();
-				text = CKEDITOR.tools.ltrim( text );
+				!this._.inPre  && ( text = CKEDITOR.tools.ltrim( text ) );
 			}
 
@@ -253,5 +257,5 @@
 		lineBreak : function()
 		{
-			if ( this._.output.length > 0 )
+			if ( !this._.inPre && this._.output.length > 0 )
 				this._.output.push( this.lineBreakChars );
 			this._.indent = 1;
@@ -268,5 +272,6 @@
 		indentation : function()
 		{
-			this._.output.push( this._.indentation );
+			if( !this._.inPre )
+				this._.output.push( this._.indentation );
 			this._.indent = 0;
 		},
