Handle XML files format properly
In A12 format of XML files changed to Android Binary XML
TWRP uses RapidXML to parse XMLs, but it don't support ABX format
So before parse check format of XML format and if it is in ABX, just ignore it for now
Change-Id: Ie40f5b3534db50143999984be22ade1d1af162e7
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 782afe1..b1e9b26 100755
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -1495,4 +1495,20 @@
exit:
return TW_DEFAULT_RECOVERY_FOLDER;
}
+
+bool TWFunc::Check_Xml_Format(const std::string filename) {
+ std::string buffer(' ', 4);
+ std::string abx_hdr("ABX\x00", 4);
+ std::ifstream File;
+ File.open(filename);
+ if (File.is_open()) {
+ File.get(&buffer[0], buffer.size());
+ File.close();
+ // Android Binary Xml start from these bytes
+ if(!buffer.compare(0, abx_hdr.size(), abx_hdr))
+ return false; // bad format, not possible to parse
+ }
+ return true; // good format, possible to parse
+}
+
#endif // ndef BUILD_TWRPTAR_MAIN