Skip to content

Commit 9e87ef6

Browse files
authored
common : improve yaml log escaping (#4080)
* logging: improve escaping in yaml output * logging: include review feedback
1 parent c7cce12 commit 9e87ef6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

common/common.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,7 @@ void dump_string_yaml_multiline(FILE * stream, const char * prop_name, const cha
11941194
if (!data_str.empty() && (std::isspace(data_str[0]) || std::isspace(data_str.back()))) {
11951195
data_str = std::regex_replace(data_str, std::regex("\n"), "\\n");
11961196
data_str = std::regex_replace(data_str, std::regex("\""), "\\\"");
1197+
data_str = std::regex_replace(data_str, std::regex(R"(\\[^n"])"), R"(\$&)");
11971198
data_str = "\"" + data_str + "\"";
11981199
fprintf(stream, "%s: %s\n", prop_name, data_str.c_str());
11991200
return;

0 commit comments

Comments
 (0)