Index: /FCKeditor/trunk/_whatsnew.html
===================================================================
--- /FCKeditor/trunk/_whatsnew.html	(revision 1789)
+++ /FCKeditor/trunk/_whatsnew.html	(revision 1790)
@@ -124,4 +124,9 @@
 			command was throwing an error if executed in an editor where its relative button
 			is not present in the toolbar.</li>
+		<li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/922">#922</a>] Implemented a
+			generic document processor for &lt;OBJECT&gt; and &lt;EMBED&gt; tags.</li>
+		<li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1831">#1831</a>] Fixed the
+			issue where the placeholder icon for &lt;EMBED&gt; tags does not always show up
+			in IE7.</li>
 	</ul>
 	<h3>
Index: /FCKeditor/trunk/editor/_source/internals/fck.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fck.js	(revision 1789)
+++ /FCKeditor/trunk/editor/_source/internals/fck.js	(revision 1790)
@@ -364,5 +364,5 @@
 		// IE doesn't support <abbr> and it breaks it. Let's protect it.
 		if ( FCKBrowserInfo.IsIE )
-			sTags += sTags.length > 0 ? '|ABBR|XML|EMBED' : 'ABBR|XML|EMBED' ;
+			sTags += sTags.length > 0 ? '|ABBR|XML|EMBED|OBJECT' : 'ABBR|XML|EMBED|OBJECT' ;
 
 		var oRegex ;
@@ -400,5 +400,5 @@
 		if ( FCKBrowserInfo.IsIE && FCK.EditorDocument )
 		{
-				FCK.EditorDocument.detachEvent("onselectionchange", Doc_OnSelectionChange ) ;
+			FCK.EditorDocument.detachEvent("onselectionchange", Doc_OnSelectionChange ) ;
 		}
 
Index: /FCKeditor/trunk/editor/_source/internals/fckconfig.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckconfig.js	(revision 1789)
+++ /FCKeditor/trunk/editor/_source/internals/fckconfig.js	(revision 1790)
@@ -177,8 +177,5 @@
 
 	// <noscript> tags (get lost in IE and messed up in FF).
-	/<noscript[\s\S]*?<\/noscript>/gi,
-
-	// Protect <object> tags. See #359.
-	/<object[\s\S]+?<\/object>/gi
+	/<noscript[\s\S]*?<\/noscript>/gi
 ] ;
 
Index: /FCKeditor/trunk/editor/_source/internals/fckdocumentprocessor.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckdocumentprocessor.js	(revision 1789)
+++ /FCKeditor/trunk/editor/_source/internals/fckdocumentprocessor.js	(revision 1790)
@@ -34,12 +34,15 @@
 FCKDocumentProcessor.Process = function( document )
 {
+	var bIsDirty = FCK.IsDirty() ;
 	var oProcessor, i = 0 ;
 	while( ( oProcessor = this._Items[i++] ) )
 		oProcessor.ProcessDocument( document ) ;
+	if ( !bIsDirty )
+		FCK.ResetIsDirty() ;
 }
 
 var FCKDocumentProcessor_CreateFakeImage = function( fakeClass, realElement )
 {
-	var oImg = FCK.EditorDocument.createElement( 'IMG' ) ;
+	var oImg = FCKTools.GetElementDocument( realElement ).createElement( 'IMG' ) ;
 	oImg.className = fakeClass ;
 	oImg.src = FCKConfig.FullBasePath + 'images/spacer.gif' ;
@@ -119,54 +122,60 @@
 }
 
-// Flash Embeds.
-var FCKFlashProcessor = FCKDocumentProcessor.AppendNew() ;
-FCKFlashProcessor.ProcessDocument = function( document )
-{
-	/*
-	Sample code:
-	This is some <embed src="/UserFiles/Flash/Yellow_Runners.swf"></embed><strong>sample text</strong>. You are&nbsp;<a name="fred"></a> using <a href="http://www.fckeditor.net/">FCKeditor</a>.
-	*/
-
-	var bIsDirty = FCK.IsDirty() ;
-
-	var aEmbeds = document.getElementsByTagName( 'EMBED' ) ;
-
-	var oEmbed ;
-	var i = aEmbeds.length - 1 ;
-	while ( i >= 0 && ( oEmbed = aEmbeds[i--] ) )
-	{
-		// IE doesn't return the type attribute with oEmbed.type or oEmbed.getAttribute("type")
-		// But it turns out that after accessing it then it doesn't gets copied later
-		var oType = oEmbed.attributes[ 'type' ] ;
-
-		// Check the extension and the type. Now it should be enough with just the type
-		// Opera doesn't return oEmbed.src so oEmbed.src.EndsWith will fail
-		if ( (oEmbed.src && oEmbed.src.EndsWith( '.swf', true )) || ( oType && oType.nodeValue == 'application/x-shockwave-flash' ) )
-		{
-			var oCloned = oEmbed.cloneNode( true ) ;
-
-			var oImg = FCKDocumentProcessor_CreateFakeImage( 'FCK__Flash', oCloned ) ;
-			oImg.setAttribute( '_fckflash', 'true', 0 ) ;
-
-			FCKFlashProcessor.RefreshView( oImg, oEmbed ) ;
-
-			oEmbed.parentNode.insertBefore( oImg, oEmbed ) ;
-			oEmbed.parentNode.removeChild( oEmbed ) ;
-		}
-	}
-
-	// Fix the IsDirty state (#1406).
-	if ( !bIsDirty )
-		FCK.ResetIsDirty() ;
-}
-
-FCKFlashProcessor.RefreshView = function( placeHolderImage, originalEmbed )
-{
-	if ( originalEmbed.getAttribute( 'width' ) > 0 )
-		placeHolderImage.style.width = FCKTools.ConvertHtmlSizeToStyle( originalEmbed.getAttribute( 'width' ) ) ;
-
-	if ( originalEmbed.getAttribute( 'height' ) > 0 )
-		placeHolderImage.style.height = FCKTools.ConvertHtmlSizeToStyle( originalEmbed.getAttribute( 'height' ) ) ;
-}
+// EMBED and OBJECT tags.
+FCKEmbedAndObjectProcessor = (function()
+{
+	var customProcessors = [] ;
+
+	var processElement = function( el )
+	{
+		var clone = el.cloneNode( true ) ;
+		var replaceElement ;
+		var fakeImg = replaceElement = FCKDocumentProcessor_CreateFakeImage( 'FCK__UnknownObject', clone ) ;
+		FCKEmbedAndObjectProcessor.RefreshView( fakeImg, el ) ;
+
+		for ( var i = 0 ; i < customProcessors.length ; i++ )
+			replaceElement = customProcessors[i]( el, replaceElement ) || replaceElement ;
+
+		if ( replaceElement != fakeImg )
+			FCKTempBin.RemoveElement( fakeImg.getAttribute( '_fckrealelement' ) ) ;
+
+		el.parentNode.replaceChild( replaceElement, el ) ;
+	}
+
+	return FCKTools.Merge( FCKDocumentProcessor.AppendNew(),
+		       {
+				ProcessDocument : function( doc )
+				{
+					// Firefox 3 would sometimes throw an unknown exception while accessing EMBEDs and OBJECTs
+					// without the setTimeout().
+					FCKTools.RunFunction( function()
+						{
+							// Process OBJECTs first, since EMBEDs can sometimes go inside OBJECTS (e.g. Flash).
+							var aObjects = doc.getElementsByTagName( 'object' );
+							for ( var i = aObjects.length - 1 ; i >= 0 ; i-- )
+								processElement( aObjects[i] ) ;
+
+							// Now process any EMBEDs left.
+							var aEmbeds = doc.getElementsByTagName( 'embed' ) ;
+							for ( var i = aEmbeds.length - 1 ; i >= 0 ; i-- )
+								processElement( aEmbeds[i] ) ;
+						} ) ;
+				},
+
+				RefreshView : function( placeHolder, original )
+				{
+					if ( original.getAttribute( 'width' ) > 0 )
+						placeHolder.style.width = FCKTools.ConvertHtmlSizeToStyle( original.getAttribute( 'width' ) ) ;
+
+					if ( original.getAttribute( 'height' ) > 0 )
+						placeHolder.style.height = FCKTools.ConvertHtmlSizeToStyle( original.getAttribute( 'height' ) ) ;
+				},
+
+				AddCustomHandler : function( func )
+				{
+					customProcessors.push( func ) ;
+				}
+			} ) ;
+} )() ;
 
 FCK.GetRealElement = function( fakeElement )
@@ -230,2 +239,11 @@
 	}
 }
+
+// Flash handler.
+FCKEmbedAndObjectProcessor.AddCustomHandler( function( el, fakeImg )
+	{
+		if ( ! ( el.nodeName.IEquals( 'embed' ) && ( el.type == 'application/x-shockwave-flash' || /\.swf($|#|\?)/i.test( el.src ) ) ) )
+			return ;
+		fakeImg.className = 'FCK__Flash' ;
+		fakeImg.setAttribute( '_fckflash', 'true', 0 ); 
+	} ) ;
Index: /FCKeditor/trunk/editor/css/fck_internal.css
===================================================================
--- /FCKeditor/trunk/editor/css/fck_internal.css	(revision 1789)
+++ /FCKeditor/trunk/editor/css/fck_internal.css	(revision 1790)
@@ -52,4 +52,14 @@
 	background-position: center center;
 	background-image: url(images/fck_flashlogo.gif);
+	background-repeat: no-repeat;
+	width: 80px;
+	height: 80px;
+}
+
+.FCK__UnknownObject
+{
+	border: #a9a9a9 1px solid;
+	background-position: center center;
+	background-image: url(images/fck_plugin.gif);
 	background-repeat: no-repeat;
 	width: 80px;
Index: /FCKeditor/trunk/editor/dialog/fck_flash/fck_flash.js
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_flash/fck_flash.js	(revision 1789)
+++ /FCKeditor/trunk/editor/dialog/fck_flash/fck_flash.js	(revision 1790)
@@ -142,5 +142,5 @@
 	}
 
-	oEditor.FCKFlashProcessor.RefreshView( oFakeImage, oEmbed ) ;
+	oEditor.FCKEmbedAndObjectProcessor.RefreshView( oFakeImage, oEmbed ) ;
 
 	return true ;
