Changeset 703

Show
Ignore:
Timestamp:
2007-08-22 18:53:08 (3 years ago)
Author:
martinkou
Message:

Fixed #268 : Simplified protect event encode/decode logic by using encodeURICompoenent() and decodeURICompoenent().
Removed FCKTools.EncodeToHex() and FCKTools.DecodeHex() since they are no longer needed.

Location:
FCKeditor/trunk/editor
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/dialog/fck_link/fck_link.js

    r694 r703  
    231231                { 
    232232                        // Decode the protected string 
    233                         onclick = FCKTools.DecodeHex( onclick ) ; 
     233                        onclick = decodeURIComponent( onclick ) ; 
    234234                         
    235235                        oPopupMatch = oRegex.OnClickPopup.exec( onclick ) ; 
     
    564564                        onclick = BuildOnClickPopup() ; 
    565565                        // Encode the attribute 
    566                         onclick = FCKTools.EncodeToHex( " onclick=\"" + onclick + "\"" )  ; 
     566                        onclick = encodeURIComponent( " onclick=\"" + onclick + "\"" )  ; 
    567567                        SetAttribute( oLink, 'onclick_fckprotectedatt', onclick ) ; 
    568568                } 
     
    575575                        { 
    576576                                // Decode the protected string 
    577                                 onclick = FCKTools.DecodeHex( onclick ) ; 
     577                                onclick = decodeURIComponent( onclick ) ; 
    578578                         
    579579                                if( oRegex.OnClickPopup.test( onclick ) ) 
  • FCKeditor/trunk/editor/_source/internals/fck.js

    r694 r703  
    755755function _FCK_ProtectEvents_ReplaceEvents( eventMatch, attName ) 
    756756{ 
    757         return ' ' + attName + '_fckprotectedatt="' + FCKTools.EncodeToHex( eventMatch ) + '"' ; 
     757        return ' ' + attName + '_fckprotectedatt="' + encodeURIComponent( eventMatch ) + '"' ; 
    758758} 
    759759 
    760760function _FCK_ProtectEvents_RestoreEvents( match, encodedOriginal ) 
    761761{ 
    762         return FCKTools.DecodeHex( encodedOriginal ) ; 
     762        return decodeURIComponent( encodedOriginal ) ; 
    763763} 
    764764 
  • FCKeditor/trunk/editor/_source/internals/fcktools.js

    r666 r703  
    417417} 
    418418 
    419 FCKTools.EncodeToHex = function( str ) 
    420 { 
    421         var symbols = FCKListsLib.HexList ; 
    422         var output = [] ; 
    423         // assume code points are 16-bits 
    424         for ( var i = 0 ; i < str.length ; i++ ) 
    425         { 
    426                 var c = str.charCodeAt( i ) ; 
    427                 var lsn = c & 0x000f ; 
    428                 var second = ( c & 0x00f0 ) >> 4 ; 
    429                 var third = ( c & 0x0f00 ) >> 8 ; 
    430                 var msn = ( c & 0xf000 ) >> 12 ; 
    431                 output.push( [ symbols[msn], symbols[third], symbols[second], symbols[lsn] ].join( "" ) ) ; 
    432         } 
    433         return output.join( "" ) ; 
    434 } 
    435  
    436 FCKTools.DecodeHex = function( hexstr ) 
    437 { 
    438         if ( hexstr.length % 4 != 0 ) 
    439                 throw "FCKTools.DecodeHex(): hexstr length must be multiple of 4." ; 
    440  
    441         var symbols = FCKListsLib.HexMap ; 
    442         var output = [] ; 
    443         for ( var i = 0 ; i < hexstr.length ; i+=4 ) 
    444         { 
    445                 var codePoint = symbols[ hexstr.charAt( i ) ] << 12 ; 
    446                 codePoint |= symbols[ hexstr.charAt( i + 1 ) ] << 8 ; 
    447                 codePoint |= symbols[ hexstr.charAt( i + 2 ) ] << 4 ; 
    448                 codePoint |= symbols[ hexstr.charAt( i + 3 ) ] ; 
    449                 output.push( String.fromCharCode( codePoint ) ) ; 
    450         } 
    451         return output.join( "" ) ; 
    452 } 
    453  
    454419FCKTools.GetDocumentPosition = function( w, node ) 
    455420{