Skip to content

Commit

Permalink
fix escaping '"' in config format
Browse files Browse the repository at this point in the history
  • Loading branch information
john30 committed Feb 14, 2021
1 parent e2f8ae0 commit 02d2845
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/lib/ebus/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,22 @@ void AttributedItem::dumpString(bool prependFieldSeparator, const string& str, o
if (prependFieldSeparator) {
*output << FIELD_SEPARATOR;
}
if (str.find_first_of(FIELD_SEPARATOR) == string::npos) {
string::size_type pos = str.find_first_of(TEXT_SEPARATOR);
if (str.find_first_of(FIELD_SEPARATOR) == string::npos
&& (pos == string::npos || (pos > 0 && pos < str.length() - 1))) {
*output << str;
} else {
} else if (pos == string::npos) {
*output << TEXT_SEPARATOR << str << TEXT_SEPARATOR;
} else {
*output << TEXT_SEPARATOR;
string::size_type last = 0;
while (pos != string::npos) {
*output << str.substr(last, pos - last);
*output << TEXT_SEPARATOR << TEXT_SEPARATOR;
last = pos+1;
pos = str.find_first_of(TEXT_SEPARATOR, last);
}
*output << str.substr(last) << TEXT_SEPARATOR;
}
}

Expand Down

0 comments on commit 02d2845

Please sign in to comment.