diff --git a/ini_reader.h b/ini_reader.h index ae718bc..97d8717 100644 --- a/ini_reader.h +++ b/ini_reader.h @@ -1,10 +1,14 @@ #ifndef INI_READER_H_INCLUDED #define INI_READER_H_INCLUDED +#include +#include #include #include #include +#include "misc.h" + typedef std::map> ini_data_struct; typedef std::multimap string_multimap; typedef std::vector string_array; @@ -119,7 +123,8 @@ public: return -1; //remove UTF-8 BOM - removeUTF8BOM(content); + if(content.compare(0, 3, "\xEF\xBB\xBF") == 0) + content = content.substr(3); bool inExcludedSection = false; std::string strLine, thisSection, curSection, itemName, itemVal; @@ -615,6 +620,16 @@ public: return current_section.size() ? SetArray(current_section, itemName, separator, Array) : -1; } + int RenameSection(std::string oldName, std::string newName) + { + if(!SectionExist(oldName)) + return -1; + auto nodeHandler = ini_content.extract(oldName); + nodeHandler.key() = newName; + ini_content.insert(std::move(nodeHandler)); + return 0; + } + /** * @brief Erase all items with the given name. */ diff --git a/main.cpp b/main.cpp index c92e892..2b2dede 100644 --- a/main.cpp +++ b/main.cpp @@ -359,7 +359,7 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS) output_content = netchToClash(nodes, base_content, rca, extra_group, target == "clashr", ext); if(upload == "true") - uploadGist("clash", upload_path, output_content, false); + uploadGist(target, upload_path, output_content, false); return output_content; } else if(target == "surge") diff --git a/misc.cpp b/misc.cpp index 5e73613..38e5c91 100644 --- a/misc.cpp +++ b/misc.cpp @@ -825,8 +825,7 @@ bool is_str_utf8(std::string data) void removeUTF8BOM(std::string &data) { - int BOM[3] = {0xef, 0xbb, 0xbf}; - if(data.compare(0, 3, (char*)BOM) == 0) + if(data.compare(0, 3, "\xEF\xBB\xBF") == 0) data = data.substr(3); } diff --git a/subexport.cpp b/subexport.cpp index 2529ff9..8935ac2 100644 --- a/subexport.cpp +++ b/subexport.cpp @@ -1545,6 +1545,7 @@ std::string netchToMellow(std::vector &nodes, std::string &base_conf, } rulesetToSurge(ini, ruleset_content_array, 2); + ini.RenameSection("Rule", "RoutingRule"); return ini.ToString(); }