Ticket #6665: 6665_3.patch

File 6665_3.patch, 3.5 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/htmldataprocessor/plugin.js

     
    9292        delete blockLikeTags.pre;
    9393        var defaultDataFilterRules =
    9494        {
    95                 elements : {},
     95                elements : {
     96                        a : function( element )
     97                        {
     98                                var attrs = element.attributes;
     99                                if ( attrs && attrs[ 'data-cke-saved-name' ] )
     100                                        attrs[ 'class' ] = ( attrs[ 'class' ] ? attrs[ 'class' ] + ' ' : '' ) + 'cke_anchor';
     101                        }
     102                },
    96103                attributeNames :
    97104                [
    98105                        // Event attributes (onXYZ) must not be directly set. They can become
     
    288295                defaultHtmlFilterRules.elements[ i ] = unprotectReadyOnly;
    289296        }
    290297
    291         var protectAttributeRegex = /<((?:a|area|img|input)\b[\s\S]*?\s)((href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))([^>]*)>/gi,
    292                 findSavedSrcRegex = /\sdata-cke-saved-src\s*=/;
     298        var protectElementRegex = /<(a|area|img|input)\b([^>]*)>/gi,
     299                protectAttributeRegex = /\b(href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi;
    293300
    294301        var protectElementsRegex = /(?:<style(?=[ >])[^>]*>[\s\S]*<\/style>)|(?:<(:?link|meta|base)[^>]*>)/gi,
    295302                encodedElementsRegex = /<cke:encoded>([^<]*)<\/cke:encoded>/gi;
     
    301308
    302309        function protectAttributes( html )
    303310        {
    304                 return html.replace( protectAttributeRegex, function( tag, beginning, fullAttr, attrName, end )
    305                         {
    306                                 // We should not rewrite the _cke_saved_src attribute (#5218)
    307                                 if ( attrName == 'src' && findSavedSrcRegex.test( tag ) )
    308                                         return tag;
    309                                 else
    310                                         return '<' + beginning + fullAttr + ' data-cke-saved-' + fullAttr + end + '>';
    311                         });
     311                return html.replace( protectElementRegex, function( element, tag, attributes )
     312                {
     313                        return '<' +  tag + attributes.replace( protectAttributeRegex, function( fullAttr, attrName )
     314                        {
     315                                // We should not rewrite the existed protected attributes, e.g. clipboard content from editor. (#5218)
     316                                if ( attributes.indexOf( 'data-cke-saved-' + attrName ) == -1 )
     317                                        return ' data-cke-saved-' + fullAttr + ' ' + fullAttr;
     318
     319                                return fullAttr;
     320                        }) + '>';
     321                });
    312322        }
    313323
    314324        function protectElements( html )
  • _source/plugins/link/dialogs/link.js

     
    225225                        advAttr( 'advId', 'id' );
    226226                        advAttr( 'advLangDir', 'dir' );
    227227                        advAttr( 'advAccessKey', 'accessKey' );
    228                         advAttr( 'advName', 'name' );
     228
     229                        retval.adv.advName =
     230                                element.data( 'cke-saved-name' )
     231                                || element.getAttribute( 'name' )
     232                                || '';
    229233                        advAttr( 'advLangCode', 'lang' );
    230234                        advAttr( 'advTabIndex', 'tabindex' );
    231235                        advAttr( 'advTitle', 'title' );
     
    12861290                                advAttr( 'advId', 'id' );
    12871291                                advAttr( 'advLangDir', 'dir' );
    12881292                                advAttr( 'advAccessKey', 'accessKey' );
    1289                                 advAttr( 'advName', 'name' );
     1293
     1294                                if ( data.adv[ 'advName' ] )
     1295                                {
     1296                                        attributes[ 'name' ] = attributes[ 'data-cke-saved-name' ] = data.adv[ 'advName' ];
     1297                                        attributes[ 'class' ] = ( attributes[ 'class' ] ? attributes[ 'class' ] + ' ' : '' ) + 'cke_anchor';
     1298                                }
     1299                                else
     1300                                        removeAttributes = removeAttributes.concat( [ 'data-cke-saved-name', 'name' ] );
     1301
    12901302                                advAttr( 'advLangCode', 'lang' );
    12911303                                advAttr( 'advTabIndex', 'tabindex' );
    12921304                                advAttr( 'advTitle', 'title' );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy