Changeset 483

Show
Ignore:
Timestamp:
2007-07-20 10:24:50 (17 months ago)
Author:
martinkou
Message:

Fixed #143 : Writing <!{PS..x}--> in source mode and then switching between source mode and WYSIWYG mode would hang the browser.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/_source/internals/fckconfig.js

    r451 r483  
    161161FCKConfig.ProtectedSource = new Object() ; 
    162162 
     163FCKConfig.ProtectedSource._GenerateCodeTag = function() 
     164{ 
     165        if ( this._CodeTag ) 
     166                return ; 
     167        var codeTag = [] ; 
     168        for ( var i = 0 ; i < 16 ; i++ ) 
     169                codeTag.push( String.fromCharCode( 0x41 + parseInt( Math.random() * 26 ) ) ) ; 
     170        this._CodeTag = codeTag.join( "" ) ; 
     171} 
     172FCKConfig.ProtectedSource._GenerateCodeTag() ; 
     173 
    163174// Initialize the regex array with the default ones. 
    164175FCKConfig.ProtectedSource.RegexEntries = [ 
     
    184195FCKConfig.ProtectedSource.Protect = function( html ) 
    185196{ 
     197        var codeTag = this._CodeTag ; 
    186198        function _Replace( protectedSource ) 
    187199        { 
    188200                var index = FCKTempBin.AddElement( protectedSource ) ; 
    189                 return '<!--{PS..' + index + '}-->' ; 
     201                return '<!--{' + codeTag + index + '}-->' ; 
    190202        } 
    191203 
     
    207219        } 
    208220 
    209         return html.replace( /(<|&lt;)!--\{PS..(\d+)\}--(>|&gt;)/g, _Replace ) ; 
     221        var regex = new RegExp( "(<|&lt;)!--\\{" + this._CodeTag + "(\\d+)\\}--(>|&gt;)", "g" ) ; 
     222        return html.replace( regex, _Replace ) ; 
    210223} 
    211224