Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BFW-5626] Support quoted INI string values #3158

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/ESP/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions lib/inih/ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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));
Expand Down