Ticket #3441: 3441_5.patch
File 3441_5.patch, 5.0 KB (added by , 15 years ago) |
---|
-
_source/core/htmlparser/text.js
5 5 6 6 (function() 7 7 { 8 // cdataNode : Element tag names which contains CDATA data type. 8 9 var spacesRegex = /[\t\r\n ]{2,}|[\t\r\n]/g; 9 10 10 11 /** … … 12 13 * @constructor 13 14 * @example 14 15 */ 15 16 CKEDITOR.htmlParser.text = function( value ) 16 17 { 17 18 /** 18 19 * The text value. … … 44 45 */ 45 46 writeHtml : function( writer, filter ) 46 47 { 47 var text = this.value; 48 var text = this.value, 49 textType = 50 this.parent.name in CKEDITOR.dtd.$cdata ? 'CDATA' : 'Text'; 48 51 49 if ( filter && !( text = filter .onText(text ) ) )52 if ( filter && !( text = filter[ 'on' + textType ].call( filter, text ) ) ) 50 53 return; 51 54 52 writer.text( text );55 writer.text( text, textType == 'CDATA' ); 53 56 } 54 57 }; 55 58 })(); -
_source/core/htmlparser/filter.js
56 56 { 57 57 return filterName( name, this._.attributeNames ); 58 58 }, 59 59 60 /** 61 * Filtering text node content. 62 * @param {Object} text The text content. 63 */ 60 64 onText : function( text ) 61 65 { 62 66 var textFilter = this._.text; … … 62 66 var textFilter = this._.text; 63 67 return textFilter ? textFilter.filter( text ) : text; 64 68 }, 69 70 /** 71 * Filtering CDATA section content. 72 */ 73 onCDATA : function( cdata ) 74 { 75 var filter = this._.cdata; 76 return filter ? filter.filter( cdata ) : cdata; 77 }, 65 78 66 79 onComment : function( commentText ) 67 80 { -
_source/core/htmlparser.js
101 102 { 102 103 var parts, 103 104 tagName, 104 nextIndex = 0; 105 nextIndex = 0, 106 cdataMode = false, 107 cdataText = []; // The collected text content inside CDATA Section. 105 108 106 109 while ( ( parts = this._.htmlPartsRegex.exec( html ) ) ) 107 110 { … … 107 110 { 108 111 var tagIndex = parts.index; 109 112 if ( tagIndex > nextIndex ) 110 this.onText( html.substring( nextIndex, tagIndex ) ); 111 112 nextIndex = this._.htmlPartsRegex.lastIndex; 113 113 { 114 var text = html.substring( nextIndex, tagIndex ); 115 if ( cdataMode ) 116 cdataText.push( text ); 117 else 118 this.onText( text ); 119 } 120 114 121 /* 115 122 "parts" is an array with the following items: 116 0 : The entire match (not used)123 0 : The entire match for opening/closing tags. 117 124 1 : Group filled with the tag name for closing tags. 118 125 2 : Group filled with the comment text. 119 126 3 : Group filled with the tag name for opening tags. … … 119 126 3 : Group filled with the tag name for opening tags. 120 127 4 : Group filled with the attributes part of opening tags. 121 128 */ 129 nextIndex = this._.htmlPartsRegex.lastIndex; 130 // Treate tags as plain text. 131 if ( cdataMode ) 132 nextIndex-= parts[ 0 ].length; 122 133 123 134 // Closing tag 124 135 if ( ( tagName = parts[ 1 ] ) ) … … 123 134 // Closing tag 124 135 if ( ( tagName = parts[ 1 ] ) ) 125 136 { 126 this.onTagClose( tagName.toLowerCase() ); 137 if ( !cdataMode || tagName in CKEDITOR.dtd.$cdata ) 138 { 139 if ( cdataMode ) 140 { 141 // Creating CDATA text. 142 this.onText( cdataText.join('') ); 143 nextIndex+= parts[ 0 ].length; 144 cdataText = []; 145 cdataMode = false; 146 } 147 this.onTagClose( tagName.toLowerCase() ); 148 } 127 149 continue; 128 150 } 129 151 152 // Ignore all tags matching inside CDATA section. 153 if ( cdataMode ) 154 continue; 155 130 156 // Opening tag 131 157 if ( ( tagName = parts[ 3 ] ) ) 132 158 { … … 148 174 attribs[ attName ] = attValue; 149 175 } 150 176 } 177 178 this.onTagOpen( tagName.toLowerCase(), attribs, selfClosing ); 151 179 152 this.onTagOpen( tagName.toLowerCase(), attribs, selfClosing ); 180 // Open CDATA mode when encounting accordinate tags. 181 if ( tagName in CKEDITOR.dtd.$cdata ) 182 cdataMode = true; 153 183 continue; 154 184 } 155 185 … … 156 186 // Comment 157 187 if( ( tagName = parts[ 2 ] ) ) 158 188 this.onComment( tagName ); 189 159 190 } 160 191 161 192 if ( html.length > nextIndex ) -
_source/core/dtd.js
67 67 $block : block, 68 68 69 69 $body : X({script:1}, block), 70 70 71 $cdata : { script:1,style:1}, 71 72 /** 72 73 * List of empty (self-closing) elements, like "br" or "img". 73 74 * @type Object