Browse Source

webui: fix ignoring exact key matches

see #2544

use updated class method for comparison
same prefix did not work with exact lengths
pull/2552/head
Maxim Prokhorov 1 year ago
parent
commit
2f54210adf
2 changed files with 6 additions and 10 deletions
  1. +1
    -5
      code/espurna/settings_helpers.h
  2. +5
    -5
      code/espurna/ws.cpp

+ 1
- 5
code/espurna/settings_helpers.h View File

@ -289,11 +289,7 @@ private:
namespace query {
inline bool samePrefix(StringView key, StringView prefix) {
if (key.length() > prefix.length()) {
return strncmp_P(key.c_str(), prefix.c_str(), prefix.length()) == 0;
}
return false;
return key.startsWith(prefix);
}
struct StringViewIterator {


+ 5
- 5
code/espurna/ws.cpp View File

@ -622,11 +622,11 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) {
}
bool _wsOnKeyCheck(espurna::StringView key, const JsonVariant&) {
return espurna::settings::query::samePrefix(key, STRING_VIEW("ws"))
|| espurna::settings::query::samePrefix(key, STRING_VIEW("adminPass"))
|| espurna::settings::query::samePrefix(key, STRING_VIEW("hostname"))
|| espurna::settings::query::samePrefix(key, STRING_VIEW("desc"))
|| espurna::settings::query::samePrefix(key, STRING_VIEW("webPort"));
return (key == STRING_VIEW("adminPass"))
|| (key == STRING_VIEW("hostname"))
|| (key == STRING_VIEW("desc"))
|| (key == STRING_VIEW("webPort"))
|| key.startsWith(STRING_VIEW("ws"));
}
void _wsOnConnected(JsonObject& root) {


Loading…
Cancel
Save