parseconfig: dash options can't specified with colon or equals
Bug: http://curl.haxx.se/bug/view.cgi?id=1297 Reported-by: Michael Osipov
This commit is contained in:
		
							
								
								
									
										28
									
								
								docs/curl.1
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								docs/curl.1
									
									
									
									
									
								
							| @@ -722,16 +722,21 @@ See this online resource for further details: | |||||||
| .IP "-K, --config <config file>" | .IP "-K, --config <config file>" | ||||||
| Specify which config file to read curl arguments from. The config file is a | Specify which config file to read curl arguments from. The config file is a | ||||||
| text file in which command line arguments can be written which then will be | text file in which command line arguments can be written which then will be | ||||||
| used as if they were written on the actual command line. Options and their | used as if they were written on the actual command line. | ||||||
| parameters must be specified on the same config file line, separated by |  | ||||||
| whitespace, colon, the equals sign or any combination thereof (however, | Options and their parameters must be specified on the same config file line, | ||||||
| the preferred separator is the equals sign). If the parameter is to contain | separated by whitespace, colon, or the equals sign. Long option names can | ||||||
| whitespace, the parameter must be enclosed within quotes. Within double | optionally be given in the config file without the initial double dashes and | ||||||
| quotes, the following escape sequences are available: \\\\, \\", \\t, \\n, | if so, the colon or equals characters can be used as separators. If the option | ||||||
| \\r and \\v. A backslash preceding any other letter is ignored. If the | is specified with one or two dashes, there can be no colon or equals character | ||||||
| first column of a config line is a '#' character, the rest of the line will be | between the option and its parameter. | ||||||
| treated as a comment. Only write one option per physical line in the config |  | ||||||
| file. | If the parameter is to contain whitespace, the parameter must be enclosed | ||||||
|  | within quotes. Within double quotes, the following escape sequences are | ||||||
|  | available: \\\\, \\", \\t, \\n, \\r and \\v. A backslash preceding any other | ||||||
|  | letter is ignored. If the first column of a config line is a '#' character, | ||||||
|  | the rest of the line will be treated as a comment. Only write one option per | ||||||
|  | physical line in the config file. | ||||||
|  |  | ||||||
| Specify the filename to -K, --config as '-' to make curl read the file from | Specify the filename to -K, --config as '-' to make curl read the file from | ||||||
| stdin. | stdin. | ||||||
| @@ -742,9 +747,6 @@ line. So, it could look similar to this: | |||||||
|  |  | ||||||
| url = "http://curl.haxx.se/docs/" | url = "http://curl.haxx.se/docs/" | ||||||
|  |  | ||||||
| Long option names can optionally be given in the config file without the |  | ||||||
| initial double dashes. |  | ||||||
|  |  | ||||||
| When curl is invoked, it always (unless \fI-q\fP is used) checks for a default | When curl is invoked, it always (unless \fI-q\fP is used) checks for a default | ||||||
| config file and uses it if found. The default config file is checked for in | config file and uses it if found. The default config file is checked for in | ||||||
| the following places in this order: | the following places in this order: | ||||||
|   | |||||||
| @@ -35,7 +35,10 @@ | |||||||
| #include "memdebug.h" /* keep this as LAST include */ | #include "memdebug.h" /* keep this as LAST include */ | ||||||
|  |  | ||||||
| #define CURLRC DOT_CHAR "curlrc" | #define CURLRC DOT_CHAR "curlrc" | ||||||
| #define ISSEP(x) (((x) == '=') || ((x) == ':')) |  | ||||||
|  | /* only acknowledge colon or equals as separators if the option was not | ||||||
|  |    specified with an initial dash! */ | ||||||
|  | #define ISSEP(x,dash) (!dash && (((x) == '=') || ((x) == ':'))) | ||||||
|  |  | ||||||
| static const char *unslashquote(const char *line, char *param); | static const char *unslashquote(const char *line, char *param); | ||||||
| static char *my_get_line(FILE *fp); | static char *my_get_line(FILE *fp); | ||||||
| @@ -123,6 +126,7 @@ int parseconfig(const char *filename, | |||||||
|     char *param; |     char *param; | ||||||
|     int lineno = 0; |     int lineno = 0; | ||||||
|     bool alloced_param; |     bool alloced_param; | ||||||
|  |     bool dashed_option; | ||||||
|  |  | ||||||
|     while(NULL != (aline = my_get_line(file))) { |     while(NULL != (aline = my_get_line(file))) { | ||||||
|       lineno++; |       lineno++; | ||||||
| @@ -146,7 +150,11 @@ int parseconfig(const char *filename, | |||||||
|  |  | ||||||
|       /* the option keywords starts here */ |       /* the option keywords starts here */ | ||||||
|       option = line; |       option = line; | ||||||
|       while(*line && !ISSPACE(*line) && !ISSEP(*line)) |  | ||||||
|  |       /* the option starts with a dash? */ | ||||||
|  |       dashed_option = option[0]=='-'?TRUE:FALSE; | ||||||
|  |  | ||||||
|  |       while(*line && !ISSPACE(*line) && !ISSEP(*line, dashed_option)) | ||||||
|         line++; |         line++; | ||||||
|       /* ... and has ended here */ |       /* ... and has ended here */ | ||||||
|  |  | ||||||
| @@ -158,7 +166,7 @@ int parseconfig(const char *filename, | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
|       /* pass spaces and separator(s) */ |       /* pass spaces and separator(s) */ | ||||||
|       while(*line && (ISSPACE(*line) || ISSEP(*line))) |       while(*line && (ISSPACE(*line) || ISSEP(*line, dashed_option))) | ||||||
|         line++; |         line++; | ||||||
|  |  | ||||||
|       /* the parameter starts here (unless quoted) */ |       /* the parameter starts here (unless quoted) */ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Daniel Stenberg
					Daniel Stenberg