From d0999f6a4a1ac69317692a33c4796df023cb16d5 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sat, 17 Dec 2016 12:38:13 -0500 Subject: conffile: allow embedded spaces in values. The code that said "Skip trailing spaces" actually skipped everything after the first space. Change to to only skip trailing spaces, or comments that start after a space. This is useful for lists: Foo: a, b, c The list handling already allows for internal spaces. Signed-off-by: NeilBrown Signed-off-by: Steve Dickson --- support/nfs/conffile.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c index e4f685c..57f58a2 100644 --- a/support/nfs/conffile.c +++ b/support/nfs/conffile.c @@ -308,14 +308,18 @@ conf_parse_line(int trans, char *line, size_t sz) line ++; j = strcspn(line, "'"); line[j] = 0; - } else + } else { /* Skip trailing spaces and comments */ for (j = 0; val[j]; j++) { - if (val[j] == '#' || val[j] == ';' || isspace(val[j])) { + if ((val[j] == '#' || val[j] == ';') + && (j == 0 || isspace(val[j-1]))) { val[j] = '\0'; break; } } + while (j && isspace(val[j-1])) + val[--j] = '\0'; + } if (strcasecmp(line, "include") == 0) conf_load(trans, val); else -- cgit