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
Re: Bugfix: XmlParser in endless loop [message #60195 is a reply to message #60191] Tue, 03 October 2023 00:55 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
zsolt wrote on Mon, 02 October 2023 18:07
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;


I am not 100% sure about removing ReadText to skip empty text, I think there are cornercases that require that (I bet it is actually a fix).

But this definitely should work:

	if(p.ReadText().GetCount() == 0) // skip empty text
		throw XmlError("Unexpected text");


(in master now)
 
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: Sat Jun 08 23:39:45 CEST 2024

Total time taken to generate the page: 0.01911 seconds