diff mbox

[05/10] conffile: allow embedded spaces in values.

Message ID 148117124518.31271.13171167527354823323.stgit@noble (mailing list archive)
State New, archived
Headers show

Commit Message

NeilBrown Dec. 8, 2016, 4:27 a.m. UTC
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 <neilb@suse.com>
---
 support/nfs/conffile.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
index e4f685c558fa..57f58a2bcdc7 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