← Commit list

13e84a6945

Joshua Rogers
Joshua Rogers
2026-09-22
SUCCESS Duration: 420s

Subject

urlapi: make curl_url_dup() copy the guessed_scheme flag

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/urlapi.c+1 -0
@@ -1448,6 +1448,7 @@ CURLU *curl_url_dup(const CURLU *in)
u->port_present = in->port_present;
u->fragment_present = in->fragment_present;
u->query_present = in->query_present;
+ u->guessed_scheme = in->guessed_scheme;
}
return u;
fail:
tests/data/Makefile.am+1 -1
@@ -1823,7 +1823,7 @@ TESTCASES = \
test1983 \
test1984 \
test1985 \
- \
+ test1989 \
test2000 \
test2001 \
test2002 \
tests/data/test1989+18 -0
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<testcase>
+<info>
+<keywords>
+libtest
+urlapi
+</keywords>
+</info>
+
+<client>
+<tool>
+lib%TESTNUMBER
+</tool>
+<name>
+curl_url_dup preserves guessed_scheme
+</name>
+</client>
+</testcase>
tests/libtest/Makefile.inc+1 -0
@@ -298,6 +298,7 @@ TESTS_C = \
lib1977.c \
lib1978.c \
lib1985.c \
+ lib1989.c \
lib2023.c \
lib2032.c \
lib2082.c \
tests/libtest/lib1989.c+67 -0
@@ -0,0 +1,67 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) Daniel Stenberg, <[email protected]>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ * SPDX-License-Identifier: curl
+ *
+ ***************************************************************************/
+#include "unitcheck.h"
+#include "urldata.h"
+#include "curl/urlapi.h"
+
+static CURLcode test_lib1989(const char *arg)
+{
+ UNITTEST_BEGIN_SIMPLE
+
+ CURLU *u = NULL;
+ CURLU *dup = NULL;
+ CURLUcode uc;
+ char *scheme = NULL;
+
+ /* Parse a scheme-less URL, letting the scheme be guessed */
+ u = curl_url();
+ if(!u)
+ goto fail;
+ uc = curl_url_set(u, CURLUPART_URL, "example.com/path", CURLU_GUESS_SCHEME);
+ fail_unless(uc == CURLUE_OK, "curl_url_set with CURLU_GUESS_SCHEME failed");
+
+ /* The original handle should reject the scheme with CURLU_NO_GUESS_SCHEME
+ since the scheme was only guessed, not explicit */
+ uc = curl_url_get(u, CURLUPART_SCHEME, &scheme, CURLU_NO_GUESS_SCHEME);
+ fail_unless(uc == CURLUE_NO_SCHEME,
+ "original handle did not reject guessed scheme");
+ curl_free(scheme);
+ scheme = NULL;
+
+ dup = curl_url_dup(u);
+ if(!dup)
+ goto fail;
+
+ /* The duplicate must still remember that the scheme was guessed */
+ uc = curl_url_get(dup, CURLUPART_SCHEME, &scheme, CURLU_NO_GUESS_SCHEME);
+ fail_unless(uc == CURLUE_NO_SCHEME,
+ "duplicated handle did not reject guessed scheme");
+ curl_free(scheme);
+
+fail:
+ curl_url_cleanup(dup);
+ curl_url_cleanup(u);
+
+ UNITTEST_END_SIMPLE
+}