Ticket #3591: 3591_6.patch

File 3591_6.patch, 6.5 KB (added by Garry Yao, 15 years ago)
  • _source/tests/plugins/htmldataprocessor/htmldataprocessor.html

     
    242242                        assert.areSame( html , dataProcessor.toDataFormat( protectedHtml ) );
    243243                },
    244244
     245                test_ticket_3591 : function()
     246                {
     247                        var editor = CKEDITOR.instances.editor1,
     248                                dataProcessor = editor.dataProcessor;
     249
     250                        dataProcessor.writer = new CKEDITOR.htmlParser.basicWriter();
     251                        var html = getTextAreaValue( '_TEXTAREA_3591' );
     252                        var protectedHtml = dataProcessor.toHtml( html );
     253
     254                        assert.areSame( getTextAreaValue( '_TEXTAREA_3591_protected' ),
     255                                protectedHtml );
     256                        assert.areSame( getTextAreaValue( '_TEXTAREA_3591' ),
     257                                dataProcessor.toDataFormat( protectedHtml ) );
     258                },
     259
     260                test_ticket_3591_2_2 : function()
     261                {
     262                        var editor = CKEDITOR.instances.editor1,
     263                                dataProcessor = editor.dataProcessor;
     264
     265                        dataProcessor.writer = new CKEDITOR.htmlParser.basicWriter();
     266                        var html = getTextAreaValue( '_TEXTAREA_3591_2' );
     267                        var protectedHtml = dataProcessor.toHtml( html );
     268
     269                        assert.areSame( getTextAreaValue( '_TEXTAREA_3591_2' ),
     270                                dataProcessor.toDataFormat( protectedHtml ) );
     271                },
     272
    245273                name : document.title
    246274        };
    247275})() );
    248276
    249 //window.onload = testCase.test_ticket_3407;
     277//window.onload = testCase.test_ticket_3591;
    250278        //]]>
    251279        </script>
    252280</head>
     
    258286<![endif]>
    259287<![endif]--><td><%Response.Write(now())%></td><td><asp:control_name id="some_id" runat="server"/></td><td><?php
    260288include ("head.html"); ?></td></tr></tbody></table><noscript>Your browser doesn't support JavaScript</noscript></textarea>
     289        <textarea id="_TEXTAREA_3591"><object><param /><param /><embed></embed></object></textarea>
     290        <textarea id="_TEXTAREA_3591_protected"><cke:object><cke:param></cke:param><cke:param></cke:param><cke:embed></cke:embed></cke:object></textarea>
     291        <textarea id="_TEXTAREA_3591_2"><object classid="clsid"><param name="movie" value="movie.swf" /><embed src="movie.swf" type="application/x-shockwave-flash"></embed></object></textarea>
    261292</body>
    262293</html>
  • _source/plugins/flash/plugin.js

     
    1919        {
    2020                var attributes = element.attributes;
    2121
    22                 return ( attributes.type != 'application/x-shockwave-flash' || !flashFilenameRegex.test( attributes.src || '' ) );
     22                return ( attributes.type == 'application/x-shockwave-flash' || flashFilenameRegex.test( attributes.src || '' ) );
    2323        }
    2424
    2525        function createFakeElement( editor, realElement )
  • _source/plugins/htmldataprocessor/plugin.js

     
    7272        delete blockLikeTags.pre;
    7373        var defaultDataFilterRules =
    7474        {
    75                 elementNames :
    76                 [
    77                         // Elements that cause problems in wysiwyg mode.
    78                         [ ( /^(object|embed|param)$/ ), 'cke:$1' ]
    79                 ],
    80 
    8175                attributeNames :
    8276                [
    8377                        // Event attributes (onXYZ) must not be directly set. They can become
     
    132126                                        // and height attributes from it.
    133127                                        if ( parent && parent.name == 'object' )
    134128                                        {
    135                                                 element.attributes.width = parent.attributes.width;
    136                                                 element.attributes.height = parent.attributes.height;
     129                                                var parentWidth = parent.attributes.width,
     130                                                        parentHeight = parent.attributes.height;
     131                                                parentWidth && ( element.attributes.width = parentWidth );
     132                                                parentHeight && ( element.attributes.height = parentHeight );
    137133                                        }
    138134                                },
    139135
     136                                // Restore param elements into self-closing.
     137                                param : function( param )
     138                                {
     139                                        param.children = [];
     140                                        param.isEmpty = true;
     141                                        return param;
     142                                },
     143
    140144                                img : function( element )
    141145                                {
    142146                                        var attribs = element.attributes;
     
    197201        }
    198202
    199203        var protectAttributeRegex = /<(?:a|area|img|input).*?\s((?:href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))/gi;
     204        var protectStyleTagsRegex = /<(style)(?=[ >])[^>]*>[^<]*<\/\1>/gi;
     205        var encodedTagsRegex = /<cke:encoded>([^<]*)<\/cke:encoded>/gi;
     206        var protectElementNamesRegex = /(<[/]?)((?:object|embed|param).*?>)/gi;
     207        var protectSelfClosingRegex = /<cke:param(.*?)\/>/gi;
    200208
    201209        function protectAttributes( html )
    202210        {
    203211                return html.replace( protectAttributeRegex, '$& _cke_saved_$1' );
    204212        }
    205213
    206         var protectStyleTagsRegex = /<(style)(?=[ >])[^>]*>[^<]*<\/\1>/gi;
    207         var encodedTagsRegex = /<cke:encoded>([^<]*)<\/cke:encoded>/gi;
    208 
    209214        function protectStyleTagsMatch( match )
    210215        {
    211216                return '<cke:encoded>' + encodeURIComponent( match ) + '</cke:encoded>';
     
    215220        {
    216221                return html.replace( protectStyleTagsRegex, protectStyleTagsMatch );
    217222        }
     223        function protectElementsNames( html )
     224        {
     225                return html.replace( protectElementNamesRegex, '$1cke:$2');
     226        }
     227        function protectSelfClosingElements( html )
     228        {
     229                return html.replace( protectSelfClosingRegex, '<cke:param$1></cke:param>' );
     230        }
    218231
    219232        function unprotectEncodedTagsMatch( match, encoded )
    220233        {
     
    298311                        if ( CKEDITOR.env.ie )
    299312                                data = protectStyleTags( data );
    300313
     314                        // Certain elements has problem to go through DOM operation, protect
     315                        // them by prefixing 'cke' namespace.(#3591)
     316                        data = protectElementsNames( data );
     317
     318                        // All none-IE browsers ignore self-closed custom elements,
     319                        // protecting them into open-close.(#3591)
     320                        data = protectSelfClosingElements( data );
     321
    301322                        // Call the browser to help us fixing a possibly invalid HTML
    302323                        // structure.
    303324                        var div = document.createElement( 'div' );
  • CHANGES.html

     
    6262                        </li>
    6363                <li><a href="http://dev.fckeditor.net/ticket/3821">#3821</a> : Fixed an issue with JAWS in which
    6464                        toolbar items are read inconsistently between virtual cursor modes.</li>
     65                <li><a href="http://dev.fckeditor.net/ticket/3591">#3591</a> : Protecting flash related elements
     66                        including '&lt;object&gt;', '&lt;embed&gt;' and '&lt;param&gt;'.
     67                        </li>
    6568        </ul>
    6669        <h3>
    6770                CKEditor 3.0 RC</h3>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy