diff --git a/doc/ESP/README.md b/doc/ESP/README.md index 379adcaf30..a2ab03c87e 100644 --- a/doc/ESP/README.md +++ b/doc/ESP/README.md @@ -28,6 +28,7 @@ ssid= enter here the SSID of your wireless network psk= enter here the valid password ``` +- Leading and trailing spaces are stripped from the INI field values; a singly (`'`) or doubly (`"`) quoted string can be used to retain such spaces, if necessary. - Store the `prusa_printer_settings.ini` file in the root folder of the USB flash drive and plug in to the printer - Run the **Setting-> Load Settings from** command from the printer - Make sure the **Settings -> Lan setting**s is set to WiFi diff --git a/lib/inih/ini.c b/lib/inih/ini.c index b4d5921211..ff6ff6c39c 100644 --- a/lib/inih/ini.c +++ b/lib/inih/ini.c @@ -51,6 +51,18 @@ static char* lskip(const char* s) return (char*)s; } +/* Strip quotes from single and double quoted strings */ +static char* unquote(char* s) +{ + int l = strlen(s); + if (l && s[0] == s[l - 1] && (s[0] == '\'' || s[0] == '"')) + { + s[l - 1] = '\0'; + s++; + } + return s; +} + /* Return pointer to first char (of chars) or inline comment in given string, or pointer to null at end of string if neither found. Inline comment must be prefixed by a whitespace character to register as a comment. */ @@ -194,6 +206,7 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, #endif value = lskip(value); rstrip(value); + value = unquote(value); /* Valid name[=:]value pair found, call handler */ strncpy0(prev_name, name, sizeof(prev_name));