]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl: find curlrc in XDG_CONFIG_HOME without leading dot
authorDaniel Stenberg <daniel@haxx.se>
Mon, 19 Aug 2024 21:22:56 +0000 (23:22 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 20 Aug 2024 06:44:44 +0000 (08:44 +0200)
If XDG_CONFIG_HOME is set, look for XDG_CONFIG_HOME/curlrc - without a
leading dot in the filename.

Fixes #12129
Reported-by: Jat Satiro
Closes #14600

src/tool_findfile.c
tests/data/test433

index 2e36a396120dda2bf03ae7ede1ab7c34d8499ae1..2496cf7db642f5378453bcf89946e07538086689 100644 (file)
@@ -51,7 +51,7 @@ struct finder {
    in the findfile() function */
 static const struct finder conf_list[] = {
   { "CURL_HOME", NULL, FALSE },
-  { "XDG_CONFIG_HOME", NULL, FALSE }, /* index == 1, used in the code */
+  { "XDG_CONFIG_HOME", NULL, TRUE },
   { "HOME", NULL, FALSE },
 #ifdef _WIN32
   { "USERPROFILE", NULL, FALSE },
@@ -102,7 +102,6 @@ static char *checkhome(const char *home, const char *fname, bool dotscore)
 char *findfile(const char *fname, int dotscore)
 {
   int i;
-  bool xdg = FALSE;
   DEBUGASSERT(fname && fname[0]);
   DEBUGASSERT((dotscore != 1) || (fname[0] == '.'));
 
@@ -114,8 +113,6 @@ char *findfile(const char *fname, int dotscore)
     if(home) {
       char *path;
       const char *filename = fname;
-      if(i == 1 /* XDG_CONFIG_HOME */)
-        xdg = TRUE;
       if(!home[0]) {
         curl_free(home);
         continue;
@@ -128,7 +125,7 @@ char *findfile(const char *fname, int dotscore)
         home = c;
       }
       if(conf_list[i].withoutdot) {
-        if(!dotscore || xdg) {
+        if(!dotscore) {
           /* this is not looking for .curlrc, or the XDG_CONFIG_HOME was
              defined so we skip the extended check */
           curl_free(home);
index f6505d0328d97d8341f30e7c05a61cc2211293ec..f1c405634501ef7a7c4d595c856100dc8906507a 100644 (file)
@@ -20,7 +20,7 @@ Content-Type: text/1
 #
 # Client-side
 <client>
-<file1 name="%LOGDIR/.curlrc">
+<file1 name="%LOGDIR/curlrc">
 --next
 header = "a: a"
 data = "curlrc read"
@@ -34,7 +34,7 @@ HOME=
 CURL_HOME=
 </setenv>
 <name>
-Verify XDG_CONFIG_HOME use to find .curlrc
+Verify XDG_CONFIG_HOME use to find curlrc
 </name>
 <command option="no-q">
 %HOSTIP:%HTTPPORT/%TESTNUMBER