From ee6df8ffb2da5ed321bf79e5f7bad901249ffebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Tue, 13 Oct 2020 15:54:55 +0200 Subject: [PATCH] Fixed double quotes escaping when saving 'attributes' to config file --- lib/ProxySQL_Config.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ProxySQL_Config.cpp b/lib/ProxySQL_Config.cpp index 9ddf788ae..49bbd8ddb 100644 --- a/lib/ProxySQL_Config.cpp +++ b/lib/ProxySQL_Config.cpp @@ -1,4 +1,5 @@ #include "proxysql_config.h" +#include "re2/re2.h" #include "proxysql.h" #include "cpp.h" @@ -108,6 +109,10 @@ int ProxySQL_Config::Write_MySQL_Users_to_configfile(std::string& data) { data += "mysql_users:\n(\n"; bool isNext = false; for (auto r : sqlite_resultset->rows) { + // Prepare fields + std::string attributes { r->fields[12] }; + RE2::GlobalReplace(&attributes, "\"", "\\\\\""); + if (isNext) data += ",\n"; data += "\t{\n"; @@ -123,7 +128,7 @@ int ProxySQL_Config::Write_MySQL_Users_to_configfile(std::string& data) { addField(data, "backend", r->fields[9], ""); addField(data, "frontend", r->fields[10], ""); addField(data, "max_connections", r->fields[11], ""); - addField(data, "attributes", r->fields[12]); + addField(data, "attributes", attributes.c_str()); addField(data, "comment", r->fields[13]); data += "\t}"; isNext = true;