Explorar o código

common : improve yaml log escaping (#4080)

* logging: improve escaping in yaml output

* logging: include review feedback
Jannis Schönleber %!s(int64=2) %!d(string=hai) anos
pai
achega
9e87ef60e1
Modificáronse 1 ficheiros con 1 adicións e 0 borrados
  1. 1 0
      common/common.cpp

+ 1 - 0
common/common.cpp

@@ -1194,6 +1194,7 @@ void dump_string_yaml_multiline(FILE * stream, const char * prop_name, const cha
     if (!data_str.empty() && (std::isspace(data_str[0]) || std::isspace(data_str.back()))) {
         data_str = std::regex_replace(data_str, std::regex("\n"), "\\n");
         data_str = std::regex_replace(data_str, std::regex("\""), "\\\"");
+        data_str = std::regex_replace(data_str, std::regex(R"(\\[^n"])"), R"(\$&)");
         data_str = "\"" + data_str + "\"";
         fprintf(stream, "%s: %s\n", prop_name, data_str.c_str());
         return;