Ticket #3441: 3441_7.patch
File 3441_7.patch, 6.2 KB (added by , 15 years ago) |
---|
-
_source/core/dtd.js
68 68 69 69 $body : X({script:1}, block), 70 70 71 $cdata : { script:1,style:1}, 72 71 73 /** 72 74 * List of empty (self-closing) elements, like "br" or "img". 73 75 * @type Object -
_source/core/htmlparser.js
73 73 onText : function() {}, 74 74 75 75 /** 76 * Function to be fired when CDATA section is found. This function 77 * should be overriden when using this class. 78 * @param {String} cdata The CDATA been found. 79 * @example 80 * var parser = new CKEDITOR.htmlParser(); 81 * parser.onCDATA = function( cdata ) 82 * { 83 * alert( cdata ); // e.g. "var hello;" 84 * }); 85 * parser.parse( "<script>var hello;</script>" ); 86 */ 87 onCDATA : function() {}, 88 89 /** 76 90 * Function to be fired when a commend is found. This function 77 91 * should be overriden when using this class. 78 92 * @param {String} comment The comment text. … … 101 115 { 102 116 var parts, 103 117 tagName, 104 nextIndex = 0; 118 nextIndex = 0, 119 cdata; // The collected data inside a CDATA section. 105 120 106 121 while ( ( parts = this._.htmlPartsRegex.exec( html ) ) ) 107 122 { 108 123 var tagIndex = parts.index; 109 124 if ( tagIndex > nextIndex ) 110 this.onText( html.substring( nextIndex, tagIndex ) ); 125 { 126 var text = html.substring( nextIndex, tagIndex ); 111 127 128 if ( cdata ) 129 cdata.push( text ); 130 else 131 this.onText( text ); 132 } 133 112 134 nextIndex = this._.htmlPartsRegex.lastIndex; 113 135 114 136 /* 115 137 "parts" is an array with the following items: 116 0 : The entire match (not used)138 0 : The entire match for opening/closing tags and comments. 117 139 1 : Group filled with the tag name for closing tags. 118 140 2 : Group filled with the comment text. 119 141 3 : Group filled with the tag name for opening tags. … … 123 145 // Closing tag 124 146 if ( ( tagName = parts[ 1 ] ) ) 125 147 { 126 this.onTagClose( tagName.toLowerCase() ); 148 tagName = tagName.toLowerCase(); 149 150 if ( cdata && CKEDITOR.dtd.$cdata[ tagName ] ) 151 { 152 // Send the CDATA data. 153 this.onCDATA( cdata.join('') ); 154 cdata = null; 155 } 156 157 if ( !cdata ) 158 { 159 this.onTagClose( tagName ); 160 continue; 161 } 162 } 163 164 // If CDATA is enabled, just save the raw match. 165 if ( cdata ) 166 { 167 cdata.push( parts[ 0 ] ); 127 168 continue; 128 169 } 129 170 … … 150 191 } 151 192 152 193 this.onTagOpen( tagName.toLowerCase(), attribs, selfClosing ); 194 195 // Open CDATA mode when finding the appropriate tags. 196 if ( !cdata && CKEDITOR.dtd.$cdata[ tagName ] ) 197 cdata = []; 198 153 199 continue; 154 200 } 155 201 -
_source/core/htmlparser/cdata.js
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 9 /** 10 * A lightweight representation of HTML text. 11 * @constructor 12 * @example 13 */ 14 CKEDITOR.htmlParser.cdata = function( value ) 15 { 16 /** 17 * The CDATA value. 18 * @type String 19 * @example 20 */ 21 this.value = value; 22 23 }; 24 25 CKEDITOR.htmlParser.cdata.prototype = 26 { 27 /** 28 * CDATA has the same type as {@link CKEDITOR.htmlParser.text} This is 29 * a constant value set to {@link CKEDITOR.NODE_TEXT}. 30 * @type Number 31 * @example 32 */ 33 type : CKEDITOR.NODE_TEXT, 34 35 /** 36 * Writes write the CDATA with no special manipulations. 37 * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML. 38 */ 39 writeHtml : function( writer ) 40 { 41 writer.write( this.value ); 42 } 43 }; 44 })(); -
_source/core/htmlparser/fragment.js
289 289 currentNode.add( new CKEDITOR.htmlParser.text( text ) ); 290 290 }; 291 291 292 parser.onCDATA = function( cdata ) 293 { 294 currentNode.add( new CKEDITOR.htmlParser.cdata( cdata ) ); 295 }; 296 292 297 parser.onComment = function( comment ) 293 298 { 294 299 currentNode.add( new CKEDITOR.htmlParser.comment( comment ) ); -
_source/core/loader.js
53 53 'core/htmlparser' : [], 54 54 'core/htmlparser/comment' : [ 'core/htmlparser' ], 55 55 'core/htmlparser/element' : [ 'core/htmlparser', 'core/htmlparser/fragment' ], 56 'core/htmlparser/fragment' : [ 'core/htmlparser', 'core/htmlparser/comment', 'core/htmlparser/text' ],56 'core/htmlparser/fragment' : [ 'core/htmlparser', 'core/htmlparser/comment', 'core/htmlparser/text', 'core/htmlparser/cdata' ], 57 57 'core/htmlparser/text' : [ 'core/htmlparser' ], 58 'core/htmlparser/cdata' : [ 'core/htmlparser' ], 58 59 'core/htmlparser/filter' : [ 'core/htmlparser' ], 59 60 'core/htmlparser/basicwriter': [ 'core/htmlparser' ], 60 61 'core/imagecacher' : [ 'core/dom/element' ], -
_source/tests/core/htmlparser/fragment.html
145 145 '<p>1</p><div>2</div><p><span>3</span></p>' ); 146 146 }, 147 147 148 test_ticket_3441 : function() 149 { 150 testParser( '<p><b>Test</b></p><script type="test">var a = "<A Href=xxx>Testing</ A>";\nGo();<\/script>', 151 '<p><b>Test</b></p><script type="test">var a = "<A Href=xxx>Testing</ A>";\nGo();<\/script>' ); 152 }, 153 148 154 name : document.title 149 155 }; 150 156 })() );