X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fhtmlparser.js;h=b652c6f5e3705b4e12e0c9ce6f69b706ac0ccf60;hb=2f22c0c38f17e75be5541089076885442aaa2377;hp=748887ed871668652929e1168aa1456c7abed0ac;hpb=8761695d9b70afe75905deaac88f78c1f8aeb32d;p=ckeditor.git diff --git a/_source/core/htmlparser.js b/_source/core/htmlparser.js index 748887e..b652c6f 100644 --- a/_source/core/htmlparser.js +++ b/_source/core/htmlparser.js @@ -1,18 +1,24 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** - * HTML text parser. - * @constructor + * Creates a {@link CKEDITOR.htmlParser} class instance. + * @class Provides an "event like" system to parse strings of HTML data. * @example + * var parser = new CKEDITOR.htmlParser(); + * parser.onTagOpen = function( tagName, attributes, selfClosing ) + * { + * alert( tagName ); + * }; + * parser.parse( '<p>Some <b>text</b>.</p>' ); */ CKEDITOR.htmlParser = function() { this._ = { - htmlPartsRegex : new RegExp( '<(?:(?:\\/([^>]+)>)|(?:!--([\\S|\\s]*?)-->)|(?:([^\\s>]+)\\s*((?:(?:[^"\'>]+)|(?:"[^"]*")|(?:\'[^\']*\'))*)\\/?>))', 'g' ) + htmlPartsRegex : new RegExp( '<(?:(?:\\/([^>]+)>)|(?:!--([\\S|\\s]*?)-->)|(?:([^\\s>]+)\\s*((?:(?:"[^"]*")|(?:\'[^\']*\')|[^"\'>])*)\\/?>))', 'g' ) }; }; @@ -92,7 +98,7 @@ CKEDITOR.htmlParser = function() * @param {String} comment The comment text. * @example * var parser = new CKEDITOR.htmlParser(); - * parser.onText = function( comment ) + * parser.onComment = function( comment ) * { * alert( comment ); // e.g. " Example " * }); @@ -172,6 +178,12 @@ CKEDITOR.htmlParser = function() if ( ( tagName = parts[ 3 ] ) ) { tagName = tagName.toLowerCase(); + + // There are some tag names that can break things, so let's + // simply ignore them when parsing. (#5224) + if ( /="/.test( tagName ) ) + continue; + var attribs = {}, attribMatch, attribsPart = parts[ 4 ], @@ -201,7 +213,7 @@ CKEDITOR.htmlParser = function() } // Comment - if( ( tagName = parts[ 2 ] ) ) + if ( ( tagName = parts[ 2 ] ) ) this.onComment( tagName ); }