Index: /FCKeditor/trunk/editor/_source/internals/fckxhtml.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckxhtml.js	(revision 123)
+++ /FCKeditor/trunk/editor/_source/internals/fckxhtml.js	(revision 124)
@@ -106,4 +106,9 @@
 FCKXHtml._AppendChildNodes = function( xmlNode, htmlNode, isBlockElement )
 {
+	// Trim block elements. This is also needed to avoid Firefox leaving extra
+	// BRs at the end of them (check made inside _AppendNode).
+	if ( isBlockElement )
+		FCKDomTools.TrimNode( htmlNode ) ;
+
 	var iCount = 0 ;
 	
@@ -123,5 +128,5 @@
 		{
 			this._AppendEntity( xmlNode, 'nbsp' ) ;
-			return ;
+			return xmlNode ;
 		}
 		
@@ -130,5 +135,5 @@
 		// Some inline elements are required to have something inside (span, strong, etc...).
 		if ( FCKListsLib.InlineChildReqElements[ sNodeName ] )
-			xmlNode.parentNode.removeChild( xmlNode ) ;
+			return null ;
 
 		// We can't use short representation of empty elements that are not marked
@@ -137,4 +142,6 @@
 			xmlNode.appendChild( this.XML.createTextNode('') ) ;
 	}
+	
+	return xmlNode ;
 }
 
@@ -204,10 +211,10 @@
 
 			if ( oTagProcessor )
-			{
 				oNode = oTagProcessor( oNode, htmlNode, xmlNode ) ;
-				if ( !oNode ) break ;
-			}
 			else
-				this._AppendChildNodes( oNode, htmlNode, Boolean( FCKListsLib.NonEmptyBlockElements[ sNodeName ] ) ) ;
+				oNode = this._AppendChildNodes( oNode, htmlNode, Boolean( FCKListsLib.NonEmptyBlockElements[ sNodeName ] ) ) ;
+
+			if ( !oNode ) 
+				break ;
 
 			xmlNode.appendChild( oNode ) ;
@@ -217,6 +224,5 @@
 		// Text Node.
 		case 3 :
-			this._AppendTextNode( xmlNode, htmlNode.nodeValue.ReplaceNewLineChars(' ') ) ;
-			break ;
+			return this._AppendTextNode( xmlNode, htmlNode.nodeValue.ReplaceNewLineChars(' ') ) ;
 
 		// Comment
@@ -271,6 +277,8 @@
 FCKXHtml._AppendTextNode = function( targetNode, textValue )
 {
-	targetNode.appendChild( this.XML.createTextNode( textValue.replace( FCKXHtmlEntities.EntitiesRegex, FCKXHtml_GetEntity ) ) ) ;
-	return ;
+	var bHadText = textValue.length > 0 ;
+	if ( bHadText )
+		targetNode.appendChild( this.XML.createTextNode( textValue.replace( FCKXHtmlEntities.EntitiesRegex, FCKXHtml_GetEntity ) ) ) ;
+	return bHadText ;
 }
 
