diff --git a/esphome/core/helpers.cpp b/esphome/core/helpers.cpp index 151d14bae2..7341bb06ed 100644 --- a/esphome/core/helpers.cpp +++ b/esphome/core/helpers.cpp @@ -234,6 +234,8 @@ bool str_contains_ignore_case_fallback(const char *haystack, const char *needle) } #ifdef USE_ESP8266 +// _P mirror of str_contains_ignore_case_fallback above; host tests cover only the fallback, +// so keep the two bodies in sync. bool str_contains_ignore_case_p(const char *haystack, PGM_P needle) { if (haystack == nullptr || needle == nullptr) { return false; diff --git a/esphome/core/helpers.h b/esphome/core/helpers.h index c1071e1553..a622dca50f 100644 --- a/esphome/core/helpers.h +++ b/esphome/core/helpers.h @@ -989,7 +989,8 @@ bool str_contains_ignore_case_fallback(const char *haystack, const char *needle) /// `str_contains_ignore_case` macro which wraps needle literals with PSTR() automatically. bool str_contains_ignore_case_p(const char *haystack, PGM_P needle); /// Case-insensitive check if needle string is contained in haystack (no heap allocation). -/// On ESP8266 the needle literal is wrapped with PSTR() so it stays in flash. +/// On ESP8266 the needle is wrapped with PSTR() so it stays in flash, which requires it to be +/// a string literal; pass a runtime needle to str_contains_ignore_case_p directly instead. #define str_contains_ignore_case(haystack, needle) str_contains_ignore_case_p(haystack, PSTR(needle)) #else /// Case-insensitive check if needle string is contained in haystack (no heap allocation).