mirror of
https://github.com/curl/curl.git
synced 2026-06-09 01:24:16 +03:00
[tool_parsecfg]: expand tilde-charaters in parameters
Tilde-characters in both quoted and unquoted strings will be expanded to the users home-directory. Fixes #2317
This commit is contained in:
parent
fe5225b5ea
commit
0efea2edfd
1 changed files with 25 additions and 0 deletions
|
|
@ -206,7 +206,32 @@ int parseconfig(const char *filename)
|
|||
#ifdef DEBUG_CONFIG
|
||||
fprintf(tool_stderr, "PARAM: \"%s\"\n",(param ? param : "(null)"));
|
||||
#endif
|
||||
|
||||
/* expand tilde-characters to the users home directory */
|
||||
if(param && param[0] == '~') {
|
||||
const char *home = curl_getenv("HOME");
|
||||
if(home) {
|
||||
char *tparam = strdup(param + 1);
|
||||
if(!tparam) {
|
||||
rc = 1; /* out of memory */
|
||||
break;
|
||||
}
|
||||
curlx_dyn_reset(&pbuf);
|
||||
if(curlx_dyn_add(&pbuf, home)) {
|
||||
rc = 1; /* out of memory */
|
||||
break;
|
||||
}
|
||||
if(curlx_dyn_add(&pbuf, tparam)) {
|
||||
rc = 1; /* out of memory */
|
||||
break;
|
||||
}
|
||||
free(tparam);
|
||||
param = curlx_dyn_ptr(&pbuf);
|
||||
}
|
||||
}
|
||||
|
||||
res = getparameter(option, param, &usedarg, config);
|
||||
|
||||
config = global->last;
|
||||
|
||||
if(!res && param && *param && !usedarg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue