Ticket #2018: 2018_pre.patch

File 2018_pre.patch, 1.7 KB (added by martinkou, 2 years ago)

Proof-of-concept patch

  • editor/_source/fckeditorapi.js

     
    9595                                                '}' + 
    9696                                                'this.StartNext();' + 
    9797                                        '}' + 
    98                                 '}' + 
     98                                '},' + 
     99 
     100                                '_UnloadList : [],' + 
     101 
     102                                '_UnloadInstanceInner : function()' + 
     103                                '{' + 
     104                                        'var name = FCKeditorAPI._UnloadList.shift(), el = null ;' + 
     105                                        'if ( ! ( el = document.getElementById( "_FCKInstance_" + name ) ) )' + 
     106                                                'delete FCKeditorAPI.Instances[name] ;' + 
     107                                        'else ' + 
     108                                                'el.removeAttribute( "id" ) ;' + 
     109                                '},' + 
     110 
     111                                '_UnloadInstance : function( name, iframe )' + 
     112                                '{' + 
     113                                        'this._UnloadList.push( name ) ;' + 
     114                                        'iframe.id = "_FCKInstance_" + name ;' + 
     115                                        'this._Root.setTimeout( this._Root.FCKeditorAPI._UnloadInstanceInner, 100 ) ;' + 
     116                                '},' + 
     117 
     118                                '_Root : window' + 
    99119                        '}' ; 
    100120 
    101121                // In IE, the "eval" function is not always available (it works with 
     
    162182        } 
    163183} 
    164184 
     185// Keep a reference to the frameElement so that it doesn't get deleted in FF3 when we need to check it at unload. 
     186if ( FCKBrowserInfo.IsGecko ) 
     187        window._FCK_frameElement = frameElement ; 
    165188function FCKeditorAPI_Cleanup() 
    166189{ 
    167         if ( ! window.FCKUnloadFlag ) 
    168                 return ; 
    169         delete FCKeditorAPI.Instances[ FCK.Name ] ; 
     190        FCKeditorAPI._UnloadInstance( FCK.Name, window._FCK_frameElement || window.frameElement ) ; 
    170191} 
    171 function FCKeditorAPI_ConfirmCleanup() 
    172 { 
    173         window.FCKUnloadFlag = true ; 
    174 } 
    175192FCKTools.AddEventListener( window, 'unload', FCKeditorAPI_Cleanup ) ; 
    176 FCKTools.AddEventListener( window, 'beforeunload', FCKeditorAPI_ConfirmCleanup) ;