X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fhtmlparser.js;h=29fee080b7bca2d677a9976e856756c4dc6e5281;hb=a272c66d841421f8bf933c16535bdcde1c4649fc;hp=e34fcb2502b17e556cea1958ebee9baa9595a280;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/core/htmlparser.js b/_source/core/htmlparser.js index e34fcb2..29fee08 100644 --- a/_source/core/htmlparser.js +++ b/_source/core/htmlparser.js @@ -1,24 +1,30 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2013, 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' ) }; }; (function() { - var attribsRegex = /([\w:]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g, + var attribsRegex = /([\w\-:.]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g, emptyAttribs = {checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1}; CKEDITOR.htmlParser.prototype = @@ -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 ); }