From: <pat...@us...> - 2007-07-25 22:02:43
|
Revision: 619 http://xml-cppdom.svn.sourceforge.net/xml-cppdom/?rev=619&view=rev Author: patrickh Date: 2007-07-25 15:02:45 -0700 (Wed, 25 Jul 2007) Log Message: ----------- Fixed a bug where a comment containing only whitespace would result in the parser getting stuck in an infinite loop. Modified Paths: -------------- trunk/cppdom/xmlparser.cpp trunk/cppdom/xmlparser.h Modified: trunk/cppdom/xmlparser.cpp =================================================================== --- trunk/cppdom/xmlparser.cpp 2007-07-16 13:09:26 UTC (rev 618) +++ trunk/cppdom/xmlparser.cpp 2007-07-25 22:02:45 UTC (rev 619) @@ -293,14 +293,22 @@ // comment follows case '!': - this->parseComment(context); + { + // Consume the -- part of the comment opening string. + ++mTokenizer; - // get next token - ++mTokenizer; - token1 = *mTokenizer; + // needed to correctly handle <!----> + Token temp_token(mTokenizer->getGeneric().substr(2)); + mTokenizer.putBack(temp_token); + this->parseComment(context); - // parse again, until we encounter some useful data - again = true; + // get next token + ++mTokenizer; + token1 = *mTokenizer; + + // parse again, until we encounter some useful data + again = true; + } break; default: Modified: trunk/cppdom/xmlparser.h =================================================================== --- trunk/cppdom/xmlparser.h 2007-07-16 13:09:26 UTC (rev 618) +++ trunk/cppdom/xmlparser.h 2007-07-25 22:02:45 UTC (rev 619) @@ -74,7 +74,11 @@ /** parses an xml tag attribute list */ bool parseAttributes(Attributes& attr); - /** parses a <!-- --> comment */ + /** + * parses a <!-- --> comment + * + * @pre The <!-- part of the comment has already been consumed. + */ void parseComment(ContextPtr& context); protected: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |