Ticket #3407: 3407_5.patch
File 3407_5.patch, 4.3 KB (added by , 15 years ago) |
---|
-
_source/core/config.js
170 170 * config.removePlugins = 'elementspath,save,font'; 171 171 */ 172 172 removePlugins : '', 173 174 /** 175 * List of regular expressions to be executed over the input HTML, 176 * indicating code that must stay untouched. 177 * @type Array 178 * @example 179 * config.protectedSource.push( /<\?[\s\S]*?\?>/g ); // PHP Code 180 * config.protectedSource.push( /<%[\s\S]*?%>/g ); // ASP Code 181 * config.protectedSource.push( /(<asp:[^\>]+>[\s|\S]*?<\/asp:[^\>]+>)|(<asp:[^\>]+\/>)/gi ); // ASP.Net Code 182 */ 183 protectedSource : [], 173 184 174 185 /** 175 186 * The editor tabindex value. -
_source/core/htmlparser/comment.js
42 42 { 43 43 var comment = this.value; 44 44 45 if ( filter && !( comment = filter.onComment( comment ) ) ) 46 return; 45 if ( filter ) 46 { 47 if ( !( comment = filter.onComment( comment ) ) ) 48 return; 49 50 if ( typeof comment != 'string' ) 51 { 52 comment.writeHtml( writer, filter ); 53 return; 54 } 55 } 47 56 48 57 writer.comment( comment ); 49 58 } -
_source/plugins/htmldataprocessor/plugin.js
8 8 // Regex to scan for at the end of blocks, which are actually placeholders. 9 9 var tailNbspRegex = /^[\t\r\n ]* $/; 10 10 11 var protectedSourceMarker = '{cke_protected}'; 12 11 13 function trimFillers( block, fromSource ) 12 14 { 13 15 // If the current node is a block, and if we're converting from source or … … 168 170 // Remove all class names starting with "cke_". 169 171 return CKEDITOR.tools.ltrim( value.replace( /(?:^|\s+)cke_[^\s]*/g, '' ) ) || false; 170 172 } 173 }, 174 175 comment : function( contents ) 176 { 177 if ( contents.substr( 0, protectedSourceMarker.length ) == protectedSourceMarker ) 178 return new CKEDITOR.htmlParser.cdata( decodeURIComponent( contents.substr( protectedSourceMarker.length ) ) ); 179 180 return contents; 171 181 } 172 182 }; 173 183 … … 216 226 return html.replace( encodedTagsRegex, unprotectEncodedTagsMatch ); 217 227 } 218 228 229 function protectSource( data, protectRegexes ) 230 { 231 var regexes = 232 [ 233 // First of any other protection, we must protect all comments 234 // to avoid loosing them (of course, IE related). 235 /<!--[\s\S]*?-->/g, 236 237 // Script tags will also be forced to be protected, otherwise 238 // IE will execute them. 239 /<script[\s\S]*?<\/script>/gi, 240 241 // <noscript> tags (get lost in IE and messed up in FF). 242 /<noscript[\s\S]*?<\/noscript>/gi 243 ] 244 .concat( protectRegexes ); 245 246 for ( var i = 0 ; i < regexes.length ; i++ ) 247 { 248 data = data.replace( regexes[i], function( match ) 249 { 250 return '<!--' + protectedSourceMarker + encodeURIComponent( match ).replace( /--/g, '%2D%2D' ) + '-->'; 251 }); 252 } 253 254 return data; 255 } 256 219 257 CKEDITOR.plugins.add( 'htmldataprocessor', 220 258 { 221 259 requires : [ 'htmlwriter' ], 222 260 223 261 init : function( editor ) 224 262 { 225 var dataProcessor = editor.dataProcessor = new CKEDITOR.htmlDataProcessor( );263 var dataProcessor = editor.dataProcessor = new CKEDITOR.htmlDataProcessor( editor ); 226 264 227 265 dataProcessor.writer.forceSimpleAmpersand = editor.config.forceSimpleAmpersand; 228 266 … … 233 271 } 234 272 }); 235 273 236 CKEDITOR.htmlDataProcessor = function( )274 CKEDITOR.htmlDataProcessor = function( editor ) 237 275 { 276 this.editor = editor; 277 238 278 this.writer = new CKEDITOR.htmlWriter(); 239 279 this.dataFilter = new CKEDITOR.htmlParser.filter(); 240 280 this.htmlFilter = new CKEDITOR.htmlParser.filter(); … … 247 287 // The source data is already HTML, but we need to clean 248 288 // it up and apply the filter. 249 289 290 data = protectSource( data, this.editor.config.protectedSource ); 291 250 292 // Before anything, we must protect the URL attributes as the 251 293 // browser may changing them when setting the innerHTML later in 252 294 // the code.