Ticket #3407: 3407_3.patch
File 3407_3.patch, 9.5 KB (added by , 15 years ago) |
---|
-
_source/core/config.js
150 150 * config.plugins = 'basicstyles,button,htmldataprocessor,toolbar,wysiwygarea'; 151 151 */ 152 152 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', 154 154 155 155 /** 156 156 * List of additional plugins to be loaded. This is a tool setting which -
_source/core/htmlparser/comment.js
45 45 if ( filter && !( comment = filter.onComment( comment ) ) ) 46 46 return; 47 47 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 } 49 56 } 50 57 }; -
_source/core/htmlparser/element.js
124 124 if ( !( element = filter.onElement( element ) ) ) 125 125 return; 126 126 127 if ( element.name == writeName )127 if ( element.name == writeName || element.type == CKEDITOR.NODE_TEXT || element.type == CKEDITOR.NODE_COMMENT ) 128 128 break; 129 129 130 130 writeName = element.name; … … 135 135 attributes = element.attributes; 136 136 } 137 137 138 if ( element.type == CKEDITOR.NODE_COMMENT || element.type == CKEDITOR.NODE_TEXT ) 139 { 140 element.writeHtml( writer ); 141 return; 142 } 143 138 144 // Open element tag. 139 145 writer.openTag( writeName, attributes ); 140 146 -
_source/core/htmlparser/filter.js
11 11 { 12 12 this._ = 13 13 { 14 regExp : [], 14 15 elementNames : [], 15 16 attributeNames : [], 16 17 elements : { $length : 0 }, … … 29 30 priority = 10; 30 31 31 32 // Add the elementNames. 33 addItemsToList( this._.regExp, rules.regExp, priority ); 34 35 // Add the elementNames. 32 36 addItemsToList( this._.elementNames, rules.elementNames, priority ); 33 37 34 38 // Add the attributeNames. -
_source/core/htmlparser/text.js
12 12 * @constructor 13 13 * @example 14 14 */ 15 CKEDITOR.htmlParser.text = function( value )15 CKEDITOR.htmlParser.text = function( value, protect ) 16 16 { 17 17 /** 18 18 * The text value. 19 19 * @type String 20 20 * @example 21 21 */ 22 this.value = value.replace( spacesRegex, ' ' );22 this.value = protect ? value : value.replace( spacesRegex, ' ' ); 23 23 24 24 /** @private */ 25 25 this._ = 26 26 { 27 protect : protect, 27 28 isBlockLike : false 28 29 }; 29 30 }; … … 46 47 { 47 48 var text = this.value; 48 49 49 if ( filter && !( text = filter.onText( text ) ) )50 if ( !this._.protect && filter && !( text = filter.onText( text ) ) ) 50 51 return; 51 52 52 53 writer.text( text ); -
_source/plugins/htmldataprocessor/plugin.js
111 111 return html.replace( protectAttributeRegex, '$& _cke_saved_$1' ); 112 112 } 113 113 114 function protectSource( html, filter ) 115 { 116 var rules = filter._.regExp; 117 118 for ( var i = 0 ; i < rules.length ; i++ ) 119 { 120 var rule = rules[ i ]; 121 html = html.replace( rule.regExp, rule.replaceWith ); 122 } 123 return html; 124 } 125 114 126 CKEDITOR.plugins.add( 'htmldataprocessor', 115 127 { 116 128 requires : [ 'htmlwriter' ], … … 140 152 // The source data is already HTML, but we need to clean 141 153 // it up and apply the filter. 142 154 143 // Before anything, we must protect the URL attributes as the 155 // Before anything, we must protect the PHP and ASP content. 156 data = protectSource( data, this.dataFilter ); 157 158 // We must protect the URL attributes as the 144 159 // browser may changing them when setting the innerHTML later in 145 160 // the code. 146 161 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+))*
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 (function() 7 { 8 var encodeContent = function( data ) 9 { 10 return encodeURIComponent( data ).replace( /--/g, "%2D%2D" ); // Protect comments in comment. 11 }; 12 13 var createProtectedElement = function( realElement ) 14 { 15 var realdata = ( typeof realElement == 'string' ) ? realElement : realElement.getOuterHtml(), 16 realdata = restoreProtectedElement( realdata, false ), // Restore inner text to avoid the second pass. 17 content = "cke_protected(" + encodeContent( realdata ) + ")", 18 doc = CKEDITOR.document; 19 20 return doc.createElement( doc.$.createComment( content ) ); 21 }; 22 23 var createProtectedParserElement = function( element ) 24 { 25 var writer = new CKEDITOR.htmlParser.basicWriter(); 26 element.writeHtml( writer ); 27 28 var content = restoreProtectedElement( writer.getHtml(), false ); // Restore inner text to avoid the second pass. 29 content = "cke_protected(" + encodeContent( content ) + ")"; 30 return new CKEDITOR.htmlParser.comment( content ); 31 }; 32 33 var restoreProtectedElement = function( content, forParser ) 34 { 35 if ( forParser ) 36 { 37 var realData = content.match( /^cke_protected\((.*?)\)$/i ); 38 if ( realData ) 39 { 40 realData = decodeURIComponent( realData[1] ); 41 return new CKEDITOR.htmlParser.text( realData, true ); // true = protect content. 42 } 43 return content; 44 } 45 else 46 { 47 content = content.replace(/<\!--cke_protected\((.*?)\)-->/g, 48 function( comment ) 49 { 50 return decodeURIComponent( 51 comment.substr( 18, ( comment.length -22 ) ) // Get the content. 52 ); 53 } 54 ); 55 return content; 56 } 57 }; 58 59 CKEDITOR.plugins.add( 'protectedsource', 60 { 61 afterInit : function( editor ) 62 { 63 var protectedSource = editor.config.protectedSource, 64 dataProcessor = editor.dataProcessor, 65 dataFilter = dataProcessor && dataProcessor.dataFilter, 66 htmlFilter = dataProcessor && dataProcessor.htmlFilter; 67 68 if ( !dataFilter || !htmlFilter ) 69 return; 70 71 var rules = 72 { 73 regExp : [], 74 elements : [] 75 }; 76 77 // Create rules. 78 for ( var i=0; i < protectedSource.length; i++ ) 79 { 80 var rule = protectedSource[ i ]; 81 if ( rule.regExp ) 82 { 83 rules.regExp.push( 84 { 85 regExp : rule.regExp, 86 replaceWith : rule.replaceWith || function ( data ) 87 { 88 return createProtectedElement( data ).getOuterHtml(); 89 } 90 } 91 ); 92 } 93 else if ( rule.element ) 94 rules.elements[ rule.element ] = createProtectedParserElement; 95 } 96 97 // Add rules: Html to Data; 98 dataFilter.addRules( rules ); 99 100 // Add rules: Data to Html. 101 htmlFilter.addRules( 102 { 103 comment : function( content ) 104 { 105 return restoreProtectedElement( content, true ); 106 } 107 } 108 ); 109 110 } 111 }); 112 })(); 113 114 CKEDITOR.config.protectedSource = 115 [ 116 { // Protect existing coments before anything. 117 regExp : /<\!--[\s\S]*?-->/g 118 }, 119 { 120 name : 'ASP', 121 regExp : /<%[\s\S]*?%>/g 122 }, 123 { 124 name : 'ASP.Net', 125 regExp : /(<asp:[^\>]+>[\s|\S]*?<\/asp:[^\>]+>)|(<asp:[^\>]+\/>)/gi 126 }, 127 { 128 name : 'php', 129 regExp : /<\?[\s\S]*?\?>/g 130 }, 131 { 132 name : 'style', 133 regExp : /<style[^>]*>(.|\n|\r)*?<\/style[^>]*>/g 134 }, 135 { 136 name : 'script', 137 element : 'script' 138 } 139 ]