diff --git a/autotest/ParseXMLErrors/Etalon.log b/autotest/ParseXMLErrors/Etalon.log new file mode 100644 index 000000000..3000d7378 --- /dev/null +++ b/autotest/ParseXMLErrors/Etalon.log @@ -0,0 +1,5 @@ +* C:\upp\out\autotest\CLANGx64.Debug.Debug_Full\ParseXMLErrors.exe 03.10.2023 00:45:27, user: cxl + +xml = +xml = +e = Unexpected text diff --git a/autotest/ParseXMLErrors/ParseXMLErrors.cpp b/autotest/ParseXMLErrors/ParseXMLErrors.cpp new file mode 100644 index 000000000..b5cd11da9 --- /dev/null +++ b/autotest/ParseXMLErrors/ParseXMLErrors.cpp @@ -0,0 +1,20 @@ +#include + +using namespace Upp; + +CONSOLE_APP_MAIN +{ + StdLogSetup(LOG_FILE | LOG_COUT); + + for(const char *xml : { " ", "" }) + try { + DDUMP(xml); + ParseXML(xml); + } + catch(XmlError e) + { + DDUMP(e); + } + + CheckLogEtalon(); +} diff --git a/autotest/ParseXMLErrors/ParseXMLErrors.upp b/autotest/ParseXMLErrors/ParseXMLErrors.upp new file mode 100644 index 000000000..9714a56ac --- /dev/null +++ b/autotest/ParseXMLErrors/ParseXMLErrors.upp @@ -0,0 +1,10 @@ +uses + Core; + +file + Etalon.log, + ParseXMLErrors.cpp; + +mainconfig + "" = ""; + diff --git a/uppsrc/Core/XML.cpp b/uppsrc/Core/XML.cpp index 013e56894..2920dc54e 100644 --- a/uppsrc/Core/XML.cpp +++ b/uppsrc/Core/XML.cpp @@ -1012,7 +1012,8 @@ static XmlNode sReadXmlNode(XmlParser& p, ParseXmlFilter *filter, dword style) m.Shrink(); return m; } - p.ReadText(); // skip empty text + if(p.ReadText().GetCount() == 0) // skip empty text + throw XmlError("Unexpected text"); return m; }