From d35a4795f16e51f5773d00dce796f6948f82dae2 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Fri, 16 Dec 2022 21:08:02 -0500 Subject: add upstream 11.29 --- zenXml/zenxml/dom.h | 3 ++- zenXml/zenxml/xml.h | 17 ++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'zenXml') diff --git a/zenXml/zenxml/dom.h b/zenXml/zenxml/dom.h index b42d05d8..ff409eb1 100644 --- a/zenXml/zenxml/dom.h +++ b/zenXml/zenxml/dom.h @@ -317,7 +317,8 @@ private: XmlDoc (const XmlDoc&) = delete; //not implemented, thanks to XmlElement::parent_ XmlDoc& operator=(const XmlDoc&) = delete; - std::string version_ {"1.0"}; + //std::string version_ {"1.0"}; -> who cares!? + std::string version_; std::string encoding_{"utf-8"}; std::string standalone_; diff --git a/zenXml/zenxml/xml.h b/zenXml/zenxml/xml.h index c87655ba..10f0ecd8 100644 --- a/zenXml/zenxml/xml.h +++ b/zenXml/zenxml/xml.h @@ -36,7 +36,6 @@ XmlDoc loadXml(const Zstring& filePath) //throw FileError { FileInputPlain fileIn(filePath); //throw FileError const size_t blockSize = fileIn.getBlockSize(); //throw FileError - const std::string xmlPrefix = "= xmlPrefix.size() + strLength(BYTE_ORDER_MARK_UTF8)) + if (!xmlPrefixChecked && buffer.size() >= strLength(BYTE_ORDER_MARK_UTF8) + strLength("")) { xmlPrefixChecked = true; - if (!startsWith(buffer, xmlPrefix) && - !startsWith(buffer, BYTE_ORDER_MARK_UTF8 + xmlPrefix)) //allow BOM! + + std::string_view bufStart = buffer; + if (startsWith(bufStart, BYTE_ORDER_MARK_UTF8)) + bufStart.remove_prefix(strLength(BYTE_ORDER_MARK_UTF8)); + + if (!startsWith(bufStart, "")) throw FileError(replaceCpy(_("File %x does not contain a valid configuration."), L"%x", fmtPath(filePath))); } @@ -423,11 +427,10 @@ private: ///Check XML input proxy for errors and map to FileError exception /** \param xmlInput XML input proxy -\param filePath Input file path \throw FileError */ inline -void checkXmlMappingErrors(const XmlIn& xmlInput, const Zstring& filePath) //throw FileError +void checkXmlMappingErrors(const XmlIn& xmlInput) //throw FileError { if (const std::vector& errors = xmlInput.getErrors(); !errors.empty()) @@ -436,7 +439,7 @@ void checkXmlMappingErrors(const XmlIn& xmlInput, const Zstring& filePath) //thr for (const std::wstring& elem : errors) msg += L'\n' + elem; - throw FileError(replaceCpy(_("Configuration file %x is incomplete. The missing elements will be set to their default values."), L"%x", fmtPath(filePath)) + L"\n\n" + msg); + throw FileError(msg); } } } -- cgit