diff --git a/src/overlay_params.cpp b/src/overlay_params.cpp index 86b1229e..aadee0be 100644 --- a/src/overlay_params.cpp +++ b/src/overlay_params.cpp @@ -576,6 +576,8 @@ parse_overlay_env(struct overlay_params *params, uint32_t num; char key[256], value[256]; while ((num = parse_string(env, key, value)) != 0) { + trim_char(key); + trim_char(value); env += num; if (!strcmp("full", key)) { bool read_cfg = params->enabled[OVERLAY_PARAM_ENABLED_read_cfg]; diff --git a/src/string_utils.h b/src/string_utils.h index 47a5acae..8751d84e 100644 --- a/src/string_utils.h +++ b/src/string_utils.h @@ -10,6 +10,7 @@ #include #include #include +#include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" @@ -127,6 +128,22 @@ static std::vector str_tokenize(const std::string& s, const std::st return v; } +static void trim_char(char* str) { + if(!str) + return; + + char* ptr = str; + int len = strlen(ptr); + + while(len-1 > 0 && isspace(ptr[len-1])) + ptr[--len] = 0; + + while(*ptr && isspace(*ptr)) + ++ptr, --len; + + memmove(str, ptr, len + 1); +} + #pragma GCC diagnostic pop #endif //MANGOHUD_STRING_UTILS_H