Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Bugfix: XmlParser in endless loop
Bugfix: XmlParser in endless loop [message #60191] Mon, 02 October 2023 18:07 Go to previous message
zsolt is currently offline  zsolt
Messages: 698
Registered: December 2005
Location: Budapest, Hungary
Contributor
Try this simple code:
ParseXML("</b>");


This function goes into an endless loop, because at the end of sReadXmlNode() function, the line
p.ReadText(); // skip empty text

doesn't do anything.

My first idea was to change it to
p.Skip();// skip empty text

It seems to be better, but the error message will not be too useful.

My proposed change:
@@ -1005,16 +1005,15 @@ static XmlNode sReadXmlNode(XmlParser& p, ParseXmlFilter *filter, dword style)
 		return m;
 	}
 	if(p.IsText()) {
 		m.CreateText(p.ReadText());
 		m.Shrink();
 		return m;
 	}
-	p.ReadText(); // skip empty text
-	return m;
+	throw XmlError("Unexpected text");
 }
 
 void ParseXmlFilter::EndTag() {}
 
 XmlNode ParseXML(XmlParser& p, dword style, ParseXmlFilter *filter)
 {
 	XmlNode r;
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: XmlParser encoding detection bugfix.
Next Topic: pitfall with storing integers in a stream
Goto Forum:
  


Current Time: Tue May 14 16:50:54 CEST 2024

Total time taken to generate the page: 0.02505 seconds