File tree Expand file tree Collapse file tree
src/modules/complianceengine/src/assessor Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,12 +20,32 @@ string GetValue(const std::string& line)
2020 {
2121 return std::string ();
2222 }
23- const auto end = line.find (' "' , start + 1 );
24- if (end == std::string::npos)
23+ // Walk from the opening quote, honouring \" and \\ escape sequences so
24+ // that MOF string values like "{\"key\":\"val\"}" are returned
25+ // unescaped as {"key":"val"} instead of being truncated at the first
26+ // inner quote.
27+ std::string result;
28+ size_t pos = start + 1 ;
29+ while (pos < line.size ())
2530 {
26- return std::string ();
31+ if (line[pos] == ' \\ ' && pos + 1 < line.size ())
32+ {
33+ const char next = line[pos + 1 ];
34+ if (next == ' "' || next == ' \\ ' )
35+ {
36+ result += next;
37+ pos += 2 ;
38+ continue ;
39+ }
40+ }
41+ else if (line[pos] == ' "' )
42+ {
43+ break ;
44+ }
45+ result += line[pos];
46+ ++pos;
2747 }
28- return line. substr (start + 1 , end - (start + 1 )) ;
48+ return result ;
2949};
3050} // anonymous namespace
3151
You can’t perform that action at this time.
0 commit comments