-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chip-tool PersistentStorage: support for CASE resumption keys #20220
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could escape the key any way we want though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes but not in any standard way such as backslash=. It would also slow down all operations. This way we only do it once. |
||
|
||
exit: | ||
return err; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is assuming that values don't actually ever start with '=', right? I guess that's true because we base64-encode the values? Might be worth documenting that...