Ticket #4475: 4475.patch

File 4475.patch, 2.1 KB (added by Alfonso Martínez de Lizarrondo, 14 years ago)

Proposed patch

  • _source/plugins/htmldataprocessor/plugin.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    200200                                        // Remove all class names starting with "cke_".
    201201                                        return CKEDITOR.tools.ltrim( value.replace( /(?:^|\s+)cke_[^\s]*/g, '' ) ) || false;
    202202                                }
    203                         },
    204 
    205                         comment : function( contents )
    206                         {
    207                                 // If this is a comment for protected source.
    208                                 if ( contents.substr( 0, protectedSourceMarker.length ) == protectedSourceMarker )
    209                                 {
    210                                         // Remove the extra marker for real comments from it.
    211                                         if ( contents.substr( protectedSourceMarker.length, 3 ) == '{C}' )
    212                                                 contents = contents.substr( protectedSourceMarker.length + 3 );
    213                                         else
    214                                                 contents = contents.substr( protectedSourceMarker.length );
    215 
    216                                         return new CKEDITOR.htmlParser.cdata( decodeURIComponent( contents ) );
    217                                 }
    218 
    219                                 return contents;
    220203                        }
    221204                };
    222205
     
    300283                        });
    301284        }
    302285
     286        function unprotectSource( html )
     287        {
     288                html = html.replace( /<!--\{cke_protected\}([\s\S]+?)-->/g, function( match, data )
     289                        {
     290                                return decodeURIComponent( data );
     291                        });
     292
     293                // If the protected source was set on an attribute, the < and > will be encoded
     294                return html.replace( /&lt;!--\{cke_protected\}([\s\S]+?)--&gt;/g, function( match, data )
     295                        {
     296                                return decodeURIComponent( data );
     297                        });
     298        }
     299
    303300        function protectSource( data, protectRegexes )
    304301        {
    305302                var protectedHtml = [],
     
    440437
    441438                        fragment.writeHtml( writer, this.htmlFilter );
    442439
    443                         return writer.getHtml( true );
     440                        var data = writer.getHtml( true );
     441
     442                        // Restore the data that has been protected
     443                        data = unprotectRealComments( data );
     444                        data = unprotectSource( data );
     445
     446                        return data;
    444447                }
    445448        };
    446449})();
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy