mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-13 09:28:02 +00:00
Improve blacklist to require precise app name matches (#1532)
* Add files via upload * Add files via upload * Add files via upload * Clang * Update ui_btngrid.cpp * Update comment
This commit is contained in:
@@ -246,13 +246,24 @@ void load_blacklist() {
|
|||||||
if (error)
|
if (error)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
blacklist_ptr = std::unique_ptr<char>(new char[f.size()]);
|
// allocating two extra bytes for leading & trailing commas
|
||||||
if (f.read(blacklist_ptr.get(), f.size()))
|
blacklist_ptr = std::unique_ptr<char>(new char[f.size() + 2]);
|
||||||
blacklist_len = f.size();
|
if (f.read(blacklist_ptr.get() + 1, f.size())) {
|
||||||
|
blacklist_len = f.size() + 2;
|
||||||
|
|
||||||
|
// replace any CR/LF characters with comma delineator, and add comma prefix/suffix, to simplify searching
|
||||||
|
char* ptr = blacklist_ptr.get();
|
||||||
|
*ptr = ',';
|
||||||
|
*(ptr + blacklist_len - 1) = ',';
|
||||||
|
for (size_t i = 0; i < blacklist_len; i++, ptr++) {
|
||||||
|
if (*ptr == 0x0D || *ptr == 0x0A)
|
||||||
|
*ptr = ',';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BtnGridView::blacklisted_app(GridItem new_item) {
|
bool BtnGridView::blacklisted_app(GridItem new_item) {
|
||||||
std::string app_name = new_item.text;
|
std::string app_name = "," + new_item.text + ",";
|
||||||
|
|
||||||
if (blacklist_len < app_name.size())
|
if (blacklist_len < app_name.size())
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user