Ticket #3407: 3407.patch
File 3407.patch, 12.1 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 ) 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_TEXT ) 139 { 140 writer.text( element.value ); 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/fakeobjects/plugin.js
11 11 { 12 12 $ : function( element ) 13 13 { 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 ); 17 16 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 18 23 if ( realElement ) 19 24 { 20 25 // If we have width/height in the element, we must move it into … … 60 65 }); 61 66 })(); 62 67 63 CKEDITOR.editor.prototype.createFakeElement = function( realElement, className, realElementType, isResizable )68 CKEDITOR.editor.prototype.createFakeElement = function( realElement, className, realElementType, isResizable, protectContent ) 64 69 { 65 70 var attributes = 66 71 { 67 72 'class' : className, 68 73 src : CKEDITOR.getUrl( 'images/spacer.gif' ), 69 _cke_realelement : encodeURIComponent( realElement.getOuterHtml() )74 _cke_realelement : encodeURIComponent( ( typeof realElement == 'string' ) ? realElement : realElement.getOuterHtml() ) 70 75 }; 71 76 if ( realElementType ) 72 77 attributes._cke_real_element_type = realElementType; 73 78 if ( isResizable ) 74 79 attributes._cke_resizable = isResizable; 80 if ( protectContent ) 81 attributes._cke_protect = true; 75 82 76 return this.document.createElement( 'img', { attributes : attributes } ); 83 var document = this.document || CKEDITOR.document; 84 return document.createElement( 'img', { attributes : attributes } ); 77 85 }; 78 86 79 CKEDITOR.editor.prototype.createFakeParserElement = function( realElement, className, realElementType, isResizable )87 CKEDITOR.editor.prototype.createFakeParserElement = function( realElement, className, realElementType, isResizable, protectContent ) 80 88 { 81 89 var writer = new CKEDITOR.htmlParser.basicWriter(); 82 90 … … 91 99 _cke_realelement : encodeURIComponent( html ) 92 100 }; 93 101 102 if ( protectContent ) 103 attributes._cke_protect = true; 104 94 105 if ( realElementType ) 95 106 attributes._cke_real_element_type = realElementType; 96 107 -
_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 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 114 125 CKEDITOR.plugins.add( 'htmldataprocessor', 115 126 { 116 127 requires : [ 'htmlwriter' ], … … 140 151 // The source data is already HTML, but we need to clean 141 152 // it up and apply the filter. 142 153 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 144 158 // browser may changing them when setting the innerHTML later in 145 159 // the code. 146 160 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 /* 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 CKEDITOR.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 80 CKEDITOR.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 88 CKEDITOR.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 ]