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   |
 |
mirek
Messages: 14257 Registered: November 2005
|
Ultimate Member |
|
|
zsolt wrote on Mon, 02 October 2023 18:07Try this simple code:
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)
|
|
|
Goto Forum:
Current Time: Tue May 13 02:33:21 CEST 2025
Total time taken to generate the page: 0.00346 seconds
|