diff options
author | B. Stack <bgstack15@gmail.com> | 2022-12-16 21:08:02 -0500 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2022-12-16 21:08:02 -0500 |
commit | d35a4795f16e51f5773d00dce796f6948f82dae2 (patch) | |
tree | b37279f6f8b354407507cc1a0e44691d6c63ffe8 /zenXml | |
parent | add upstream 11.28 (diff) | |
download | FreeFileSync-d35a4795f16e51f5773d00dce796f6948f82dae2.tar.gz FreeFileSync-d35a4795f16e51f5773d00dce796f6948f82dae2.tar.bz2 FreeFileSync-d35a4795f16e51f5773d00dce796f6948f82dae2.zip |
add upstream 11.2911.29
Diffstat (limited to 'zenXml')
-rw-r--r-- | zenXml/zenxml/dom.h | 3 | ||||
-rw-r--r-- | zenXml/zenxml/xml.h | 17 |
2 files changed, 12 insertions, 8 deletions
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 = "<?xml version="; bool xmlPrefixChecked = false; std::string buffer; @@ -48,11 +47,16 @@ XmlDoc loadXml(const Zstring& filePath) //throw FileError buffer.resize(buffer.size() - blockSize + bytesRead); //caveat: unsigned arithmetics //quick test whether input is an XML: avoid loading large binary files up front! - if (!xmlPrefixChecked && buffer.size() >= xmlPrefix.size() + strLength(BYTE_ORDER_MARK_UTF8)) + if (!xmlPrefixChecked && buffer.size() >= strLength(BYTE_ORDER_MARK_UTF8) + strLength("<?xml?>")) { 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, "<?xml ") && + !startsWith(bufStart, "<?xml?>")) 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<std::wstring>& 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); } } } |