]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
parseconfig: warn if unquoted white spaces are detected
authorDaniel Stenberg <daniel@haxx.se>
Mon, 9 Dec 2013 07:19:04 +0000 (08:19 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 9 Dec 2013 22:30:09 +0000 (23:30 +0100)
Commit 0db811b6 made some existing config files pass on unexpected
values to libcurl that made it somewhat hard to track down what was
really going on.

This code detects unquoted white spaces in the parameter when parsing a
config file as that would be one symptom and it is generally a bad
syntax anyway.

src/tool_parsecfg.c

index 4d5145bcce700f1a7b94e3d927067d7c2152446b..71be83d71efe91cd25be41c436b472c00538e5d0 100644 (file)
@@ -188,6 +188,24 @@ int parseconfig(const char *filename,
         while(*line && !ISSPACE(*line))
           line++;
         *line = '\0'; /* zero terminate */
+
+        /* to detect mistakes better, see if there's data following */
+        line++;
+        /* pass all spaces */
+        while(*line && ISSPACE(*line))
+          line++;
+
+        switch(*line) {
+        case '\0':
+        case '\r':
+        case '\n':
+        case '#': /* comment */
+          break;
+        default:
+          warnf(config, "%s:%d: warning: '%s' uses unquoted white space in the"
+                " line that may cause side-effects!\n",
+                filename, lineno, option);
+        }
       }
 
       if(param && !*param) {