Ticket #4475: 4475_2.patch
File 4475_2.patch, 3.8 KB (added by , 13 years ago) |
---|
-
_source/plugins/wysiwygarea/plugin.js
902 902 loadData : function( data ) 903 903 { 904 904 isLoadingData = true; 905 editor._.dataStore = { id : 1 }; 905 906 906 907 var config = editor.config, 907 908 fullPage = config.fullPage, -
_source/plugins/htmldataprocessor/plugin.js
238 238 // Remove all class names starting with "cke_". 239 239 return CKEDITOR.tools.ltrim( value.replace( /(?:^|\s+)cke_[^\s]*/g, '' ) ) || false; 240 240 } 241 }, 242 243 comment : function( contents ) 244 { 245 // If this is a comment for protected source. 246 if ( contents.substr( 0, protectedSourceMarker.length ) == protectedSourceMarker ) 247 { 248 // Remove the extra marker for real comments from it. 249 if ( contents.substr( protectedSourceMarker.length, 3 ) == '{C}' ) 250 contents = contents.substr( protectedSourceMarker.length + 3 ); 251 else 252 contents = contents.substr( protectedSourceMarker.length ); 253 254 return new CKEDITOR.htmlParser.cdata( decodeURIComponent( contents ) ); 255 } 256 257 return contents; 258 } 241 } 259 242 }; 260 243 261 244 if ( CKEDITOR.env.ie ) … … 379 362 }); 380 363 } 381 364 382 function protectSource( data, protectRegexes)365 function unprotectSource( html, editor ) 383 366 { 367 var store = editor._.dataStore; 368 return html.replace( /<!--\{cke_protected\}([\s\S]+?)-->/g, function( match, data ) 369 { 370 return decodeURIComponent( data ); 371 }).replace( /\{cke_protected_(\d+)\}/g, function( match, id ) 372 { 373 return store[ id ]; 374 }); 375 } 376 377 function protectSource( data, editor ) 378 { 384 379 var protectedHtml = [], 380 protectRegexes = editor.config.protectedSource, 381 store = editor._.dataStore, 385 382 tempRegex = /<\!--\{cke_temp(comment)?\}(\d*?)-->/g; 386 383 387 384 var regexes = … … 414 411 return protectedHtml[ id ]; 415 412 } 416 413 ); 417 return '<!--{cke_temp}' + ( protectedHtml.push( match ) - 1 ) + '-->'; 414 415 // Avoid protecting over protected, e.g. /\{.*?\}/ 416 return /cke_temp(comment)?/.test( match ) ? match 417 : '<!--{cke_temp}' + ( protectedHtml.push( match ) - 1 ) + '-->'; 418 418 }); 419 419 } 420 420 data = data.replace( tempRegex, function( $, isComment, id ) … … 425 425 '-->'; 426 426 } 427 427 ); 428 return data; 428 429 // Different protection pattern is used for those that 430 // live in attributes to avoid from being HTML encoded. 431 return data.replace( /(['"]).*?\1/g, function ( match ) 432 { 433 return match.replace( /<!--\{cke_protected\}([\s\S]+?)-->/g, function( match, data ) 434 { 435 store[ store.id ] = decodeURIComponent( data ); 436 return '{cke_protected_'+ store.id++ + '}'; 437 }) 438 }); 429 439 } 430 440 431 441 CKEDITOR.plugins.add( 'htmldataprocessor', … … 471 481 // The source data is already HTML, but we need to clean 472 482 // it up and apply the filter. 473 483 474 data = protectSource( data, this.editor .config.protectedSource);484 data = protectSource( data, this.editor ); 475 485 476 486 // Before anything, we must protect the URL attributes as the 477 487 // browser may changing them when setting the innerHTML later in … … 533 543 534 544 fragment.writeHtml( writer, this.htmlFilter ); 535 545 536 return writer.getHtml( true ); 546 var data = writer.getHtml( true ); 547 548 // Restore those non-HTML protected source. (#4475,#4880) 549 data = unprotectRealComments( data ); 550 data = unprotectSource( data, this.editor ); 551 552 return data; 537 553 } 538 554 }; 539 555 })();