Ticket #3591: 3591_2.patch

File 3591_2.patch, 1.6 KB (added by Garry Yao, 15 years ago)
  • plugins/htmldataprocessor/plugin.js

     
    77{
    88        var defaultDataFilterRules =
    99        {
    10                 elementNames :
    11                 [
    12                         // Elements that cause problems in wysiwyg mode.
    13                         [ ( /^(object|embed|param)$/ ), 'cke:$1' ]
    14                 ],
    15 
    1610                attributeNames :
    1711                [
    1812                        // Event attributes (onXYZ) must not be directly set. They can become
     
    10599        }
    106100
    107101        var protectAttributeRegex = /<(?:a|area|img|input).*?\s((?:href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))/gi;
    108 
     102        var protectElementNamesRegex = /(<[/]?)(object|embed|param)(.*?>)/gi;
    109103        function protectAttributes( html )
    110104        {
    111105                return html.replace( protectAttributeRegex, '$& _cke_saved_$1' );
    112106        }
     107        function protectElementsNames( html )
     108        {
     109                return html.replace( protectElementNamesRegex, '$1cke:$2$3');
     110        }
    113111
    114112        CKEDITOR.plugins.add( 'htmldataprocessor',
    115113        {
     
    145143                        // the code.
    146144                        data = protectAttributes( data );
    147145
     146                        // Certain elements has problem during native DOM operation, we transform them into
     147                        // their 'agent' intead, prefixing with 'cke:' to become a custom element.
     148                        data = protectElementsNames( data );
     149
    148150                        // Call the browser to help us fixing a possibly invalid HTML
    149151                        // structure.
    150                         var div = document.createElement( 'div' );
     152                        var div = document.createElement( 'body' );
    151153                        div.innerHTML = data;
    152154
    153155                        // Now use our parser to make further fixes to the structure, as
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy