Skip to content

Commit

Permalink
chip-tool PersistentStorage: quickfix for keys containing '='
Browse files Browse the repository at this point in the history
  • Loading branch information
bluebin14 committed Jul 1, 2022
1 parent 6c6dca3 commit bf2dec2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions examples/chip-tool/config/PersistentStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@ std::string Base64ToString(const std::string & b64Value)
return std::string(reinterpret_cast<const char *>(buffer.get()), len);
}

void AdjustConfig(Sections & sections)
{
Section section = sections[kDefaultSectionName];
Section newSection;

for (auto it = section.begin(); it != section.end(); it++)
{
std::string key = it->first;
const char * value = it->second.c_str();

while (value[0] == '=')
{
key += '=';
value++;
}

newSection[key] = value;
}

sections[kDefaultSectionName] = newSection;
}

} // namespace

CHIP_ERROR PersistentStorage::Init(const char * name)
Expand All @@ -95,6 +117,10 @@ CHIP_ERROR PersistentStorage::Init(const char * name)
mName = name;
mConfig.parse(ifs);
ifs.close();

// inipp.h cannot deal with keys containing '=' and does not support escapes either
AdjustConfig(mConfig.sections);

exit:
return err;
}
Expand Down

0 comments on commit bf2dec2

Please sign in to comment.