Ticket #3407: 3407.patch

File 3407.patch, 12.1 KB (added by Artur Formella, 15 years ago)
  • _source/core/config.js

     
    150150         * config.plugins = 'basicstyles,button,htmldataprocessor,toolbar,wysiwygarea';
    151151         */
    152152
    153         plugins : 'about,basicstyles,blockquote,button,clipboard,colorbutton,contextmenu,elementspath,enterkey,entities,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,pastefromword,pastetext,preview,print,removeformat,save,smiley,showblocks,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
     153        plugins : 'about,basicstyles,blockquote,button,clipboard,colorbutton,contextmenu,elementspath,enterkey,entities,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,pastefromword,pastetext,preview,print,protectedsource,removeformat,save,smiley,showblocks,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
    154154
    155155        /**
    156156         * List of additional plugins to be loaded. This is a tool setting which
  • _source/core/htmlparser/comment.js

     
    4545                if ( filter && !( comment = filter.onComment( comment ) ) )
    4646                        return;
    4747
    48                 writer.comment( comment );
     48                if ( typeof comment == 'string' )
     49                        writer.comment( comment );
     50                else
     51                {
     52                        var fragment = new CKEDITOR.htmlParser.fragment();
     53                        fragment.add( comment )
     54                        fragment.writeHtml( writer, filter );
     55                }
    4956        }
    5057};
  • _source/core/htmlparser/element.js

     
    124124                                        if ( !( element = filter.onElement( element ) ) )
    125125                                                return;
    126126
    127                                         if ( element.name == writeName )
     127                                        if ( element.name == writeName || element.type == CKEDITOR.NODE_TEXT )
    128128                                                break;
    129129
    130130                                        writeName = element.name;
     
    135135                                attributes = element.attributes;
    136136                        }
    137137
     138                        if ( element.type == CKEDITOR.NODE_TEXT )
     139                        {
     140                                writer.text( element.value );
     141                                return;
     142                        }
     143                         
    138144                        // Open element tag.
    139145                        writer.openTag( writeName, attributes );
    140146
  • _source/core/htmlparser/filter.js

     
    1111                {
    1212                        this._ =
    1313                        {
     14                                regExp : [],
    1415                                elementNames : [],
    1516                                attributeNames : [],
    1617                                elements : { $length : 0 },
     
    2930                                        priority = 10;
    3031
    3132                                // Add the elementNames.
     33                                addItemsToList( this._.regExp, rules.regExp, priority );
     34
     35                                // Add the elementNames.
    3236                                addItemsToList( this._.elementNames, rules.elementNames, priority );
    3337
    3438                                // Add the attributeNames.
  • _source/core/htmlparser/text.js

     
    1212         * @constructor
    1313         * @example
    1414         */
    15         CKEDITOR.htmlParser.text = function( value )
     15        CKEDITOR.htmlParser.text = function( value, protect )
    1616        {
    1717                /**
    1818                 * The text value.
    1919                 * @type String
    2020                 * @example
    2121                 */
    22                 this.value = value.replace( spacesRegex, ' ' );
     22                this.value = protect ? value : value.replace( spacesRegex, ' ' );
    2323
    2424                /** @private */
    2525                this._ =
    2626                {
     27                        protect : protect,
    2728                        isBlockLike : false
    2829                };
    2930        };
     
    4647                {
    4748                        var text = this.value;
    4849
    49                         if ( filter && !( text = filter.onText( text ) ) )
     50                        if ( !this._.protect && filter && !( text = filter.onText( text ) ) )
    5051                                return;
    5152
    5253                        writer.text( text );
  • _source/plugins/fakeobjects/plugin.js

     
    1111                {
    1212                        $ : function( element )
    1313                        {
    14                                 var realHtml = element.attributes._cke_realelement,
    15                                         realFragment = realHtml && new CKEDITOR.htmlParser.fragment.fromHtml( decodeURIComponent( realHtml ) ),
    16                                         realElement = realFragment && realFragment.children[ 0 ];
     14                                var realHtml = element.attributes && element.attributes._cke_realelement;
     15                                realHtml = realHtml && decodeURIComponent( realHtml );
    1716
     17                                if ( realHtml && element.attributes._cke_protect )
     18                                        return new CKEDITOR.htmlParser.text( realHtml, true );
     19
     20                                var realFragment = realHtml && new CKEDITOR.htmlParser.fragment.fromHtml( realHtml ),
     21                                realElement = realFragment && realFragment.children[ 0 ];
     22
    1823                                if ( realElement )
    1924                                {
    2025                                        // If we have width/height in the element, we must move it into
     
    6065        });
    6166})();
    6267
    63 CKEDITOR.editor.prototype.createFakeElement = function( realElement, className, realElementType, isResizable )
     68CKEDITOR.editor.prototype.createFakeElement = function( realElement, className, realElementType, isResizable, protectContent )
    6469{
    6570        var attributes =
    6671        {
    6772                'class' : className,
    6873                src : CKEDITOR.getUrl( 'images/spacer.gif' ),
    69                 _cke_realelement : encodeURIComponent( realElement.getOuterHtml() )
     74                _cke_realelement : encodeURIComponent( ( typeof realElement == 'string' ) ? realElement : realElement.getOuterHtml() )
    7075        };
    7176        if ( realElementType )
    7277                attributes._cke_real_element_type = realElementType;
    7378        if ( isResizable )
    7479                attributes._cke_resizable = isResizable;
     80        if ( protectContent )
     81                attributes._cke_protect = true;
    7582
    76         return this.document.createElement( 'img', { attributes : attributes } );
     83        var document = this.document || CKEDITOR.document;
     84        return document.createElement( 'img', { attributes : attributes } );
    7785};
    7886
    79 CKEDITOR.editor.prototype.createFakeParserElement = function( realElement, className, realElementType, isResizable )
     87CKEDITOR.editor.prototype.createFakeParserElement = function( realElement, className, realElementType, isResizable, protectContent )
    8088{
    8189        var writer = new CKEDITOR.htmlParser.basicWriter();
    8290
     
    9199                _cke_realelement : encodeURIComponent( html )
    92100        };
    93101
     102        if ( protectContent )
     103                attributes._cke_protect = true;
     104
    94105        if ( realElementType )
    95106                attributes._cke_real_element_type = realElementType;
    96107
  • _source/plugins/htmldataprocessor/plugin.js

     
    111111                return html.replace( protectAttributeRegex, '$& _cke_saved_$1' );
    112112        }
    113113
     114        function protectSource( html, filter )
     115        {
     116                var rules = filter._.regExp;
     117                for ( var i = 0 ; i < rules.length ; i++ )
     118                {
     119                        var rule = rules[ i ];
     120                        html = html.replace( rule.regExp, rule.replaceWith );
     121                }
     122                return html;
     123        }
     124
    114125        CKEDITOR.plugins.add( 'htmldataprocessor',
    115126        {
    116127                requires : [ 'htmlwriter' ],
     
    140151                        // The source data is already HTML, but we need to clean
    141152                        // it up and apply the filter.
    142153
    143                         // Before anything, we must protect the URL attributes as the
     154                        // Before anything, we must protect the PHP and ASP content.
     155                        data = protectSource( data, this.dataFilter );
     156
     157                        // We must protect the URL attributes as the
    144158                        // browser may changing them when setting the innerHTML later in
    145159                        // the code.
    146160                        data = protectAttributes( data );
  • _source/plugins/protectedsource/plugin.js

    Property changes on: _source\plugins\protectedsource
    ___________________________________________________________________
    Added: bugtraq:label
       + Ticket
    Added: bugtraq:url
       + http://dev.fckeditor.net/ticket/%BUGID%
    Added: webviewer:pathrevision
       + http://dev.fckeditor.net/browser/%PATH%?rev=%REVISION% 
    Added: webviewer:revision
       + http://dev.fckeditor.net/changeset/%REVISION%
    Added: bugtraq:logregex
       + (?:ticket: *|#)(\d+) *(?:, *(\d+))*
    
    
    
    Property changes on: _source\plugins\protectedsource\images
    ___________________________________________________________________
    Added: bugtraq:label
       + Ticket
    Added: bugtraq:url
       + http://dev.fckeditor.net/ticket/%BUGID%
    Added: webviewer:pathrevision
       + http://dev.fckeditor.net/browser/%PATH%?rev=%REVISION% 
    Added: webviewer:revision
       + http://dev.fckeditor.net/changeset/%REVISION%
    Added: bugtraq:logregex
       + (?:ticket: *|#)(\d+) *(?:, *(\d+))*
    
    
    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
    
    Property changes on: _source\plugins\protectedsource\images\code.gif
    ___________________________________________________________________
    Added: svn:mime-type
       + application/octet-stream
    
     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6CKEDITOR.plugins.add( 'protectedsource',
     7{
     8        requires : [ 'fakeobjects' ],
     9
     10        afterInit : function( editor )
     11        {
     12                var protectedSource = editor.config.protectedSource;
     13                if ( !protectedSource )
     14                        return;
     15
     16                var dataProcessor = editor.dataProcessor,
     17                        dataFilter = dataProcessor && dataProcessor.dataFilter,
     18                        htmlFilter = dataProcessor && dataProcessor.htmlFilter;
     19
     20                if ( !dataFilter || !htmlFilter )
     21                        return;
     22
     23                editor.addCss(
     24                        'img.cke_code' +
     25                        '{' +
     26                                'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/code.gif' ) + ');' +
     27                                'background-position: center center;' +
     28                                'background-repeat: no-repeat;' +
     29                                'border: 1px solid #a9a9a9;' +
     30                                'width: 32px;' +
     31                                'height: 32px;' +
     32                        '}'     );
     33               
     34                var regExpRules =
     35                {
     36                        regExp : []
     37                };
     38
     39                for ( var i=0; i < protectedSource.length; i++ )
     40                {
     41                        var rule = protectedSource[ i ];
     42                        regExpRules.regExp.push(
     43                                (function( rule )                       // Remember proper context.
     44                                        {
     45                                                return {
     46                                                        regExp : rule.regExp,
     47                                                        replaceWith : function ( data )
     48                                                        {
     49                                                                return ( rule.editable ?
     50                                                                        editor.createFakeElement( data, rule.className || "cke_code", rule.name, false, true ).getOuterHtml()
     51                                                                :
     52                                                                        editor.createProtectedElement( data ).getOuterHtml());
     53                                                        }
     54                                                };
     55                                        })( rule )
     56                        );
     57                }
     58
     59                // Add rules: Html to Data;
     60                dataFilter.addRules( regExpRules );
     61                       
     62                // Add rules: Data to Html.
     63                htmlFilter.addRules(
     64                        {
     65                                comment : function( content )
     66                                {
     67                                        var realData = content.match( /^cke_protected\((.*?)\)$/i );
     68                                        if ( realData )
     69                                        {
     70                                                realData = decodeURIComponent( realData[1] );
     71                                                return new CKEDITOR.htmlParser.text( realData, true );
     72                                        }
     73                                }
     74                        }
     75                );
     76        }
     77});
     78
     79
     80CKEDITOR.editor.prototype.createProtectedElement = function( realElement )
     81{
     82        var content = "cke_protected(" + encodeURIComponent( ( typeof realElement == 'string' ) ? realElement : realElement.getOuterHtml() ) + ")";
     83        var document = this.document || CKEDITOR.document;
     84
     85        return document.createElement( document.$.createComment( content ) );
     86};
     87
     88CKEDITOR.config.protectedSource =
     89[
     90        {
     91                name : "ASP",
     92                regExp : /<%[\s\S]*?%>/g,
     93                editable : false
     94        },
     95        {
     96                name : "ASP.Net",
     97                regExp : /(<asp:[^\>]+>[\s|\S]*?<\/asp:[^\>]+>)|(<asp:[^\>]+\/>)/gi,
     98                editable : false
     99        },
     100        {
     101                name : "php",
     102                regExp : /<\?[\s\S]*?\?>/g,
     103                editable : false
     104        },
     105        {
     106                name : "script",
     107                regExp : /<script[^>]*>(.|\n|\r)*?<\/script[^>]*>/g,
     108                editable : false
     109        }
     110]
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy