Index: /CKEditor/branches/prototype/_source/plugins/link/dialogs/link.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/link/dialogs/link.js	(revision 2754)
+++ /CKEditor/branches/prototype/_source/plugins/link/dialogs/link.js	(revision 2755)
@@ -569,4 +569,6 @@
 		onShow : function()
 		{
+			// IE BUG: Selection must be in the editor for getSelection() to work.
+			this.restoreSelection();
 			var editor = this.getParentEditor(),
 				selection = editor.getSelection(),
@@ -607,5 +609,5 @@
 			{
 				var rangeRoot = ranges[0].getCommonAncestor(),
-					element = rangeRoot && rangeRoot.getAscendant( 'a' );
+					element = rangeRoot && ( ( rangeRoot.getName() == 'a' && rangeRoot ) || rangeRoot.getAscendant( 'a' ) );
 				if ( element && element.getAttribute( 'href' ) )
 				{
@@ -706,4 +708,8 @@
 			if ( !this._.selectedElement )
 			{
+				// IE BUG: Selection must be in the editor for getSelection() to work.
+				this.restoreSelection();
+				this.clearSavedSelection();
+
 				// Create element if current selection is collapsed.
 				var selection = editor.getSelection(),
@@ -733,7 +739,4 @@
 					}
 				}
-			
-				// style.apply() changed the selection already, so clear the old one.
-				this.clearSavedSelection();
 			}
 			else
Index: /CKEditor/branches/prototype/_source/plugins/selection/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/selection/plugin.js	(revision 2754)
+++ /CKEditor/branches/prototype/_source/plugins/selection/plugin.js	(revision 2755)
@@ -139,5 +139,21 @@
 CKEDITOR.editor.prototype.getSelection = function()
 {
-	return this.document ? this.document.getSelection() : null;
+	var retval = this.document ? this.document.getSelection() : null;
+
+	/**
+	 * IE BUG: The selection's document may be a different document than the
+	 * editor document. Return null if that's the case.
+	 */
+	if ( retval && CKEDITOR.env.ie )
+	{
+		var range = retval.getNative().createRange();
+		if ( !range )
+			return null;
+		else if ( range.item )
+			return range.item[0].ownerDocument == this.document.$ ? retval : null;
+		else
+			return range.parentElement().ownerDocument == this.document.$ ? retval : null;
+	}
+	return retval;
 };
 
