diff --git a/tests.json b/tests.json index 2e440752..ce4e7f99 100644 --- a/tests.json +++ b/tests.json @@ -2572,5 +2572,34 @@ "returncode": 10, "stdout": "" } + }, + { + "required": ["no-guess-scheme"], + "input": { + "arguments": [ + "example.com", + "--set", + "scheme?=https" + ] + }, + "expected": { + "stdout": "https://example.com/\n", + "stderr": "", + "returncode": 0 + } + }, + { + "input": { + "arguments": [ + "ftp://example.com", + "--set", + "scheme?=https" + ] + }, + "expected": { + "stdout": "ftp://example.com/\n", + "stderr": "", + "returncode": 0 + } } ] diff --git a/trurl.c b/trurl.c index 47e31704..d4a981c3 100644 --- a/trurl.c +++ b/trurl.c @@ -72,6 +72,11 @@ typedef enum { #if CURL_AT_LEAST_VERSION(7,30,0) #define SUPPORTS_IMAP_OPTIONS #endif +#if CURL_AT_LEAST_VERSION(8,9,0) +#define SUPPORTS_NO_GUESS_SCHEME +#else +#define CURLU_NO_GUESS_SCHEME 0 +#endif #define OUTPUT_URL 0 /* default */ #define OUTPUT_SCHEME 1 @@ -276,30 +281,33 @@ static void show_version(void) fprintf(stdout, "%s version %s libcurl/%s [built-with %s]\n", PROGNAME, TRURL_VERSION_TXT, data->version, LIBCURL_VERSION); fprintf(stdout, "features:"); -#ifdef SUPPORTS_PUNYCODE - if(supports_puny) - fprintf(stdout, " punycode"); -#endif -#ifdef SUPPORTS_ALLOW_SPACE - fprintf(stdout, " white-space"); -#endif -#ifdef SUPPORTS_ZONEID - fprintf(stdout, " zone-id"); +#ifdef SUPPORTS_IMAP_OPTIONS + if(supports_imap) + fprintf(stdout, " imap-options"); #endif -#ifdef SUPPORTS_URL_STRERROR - fprintf(stdout, " url-strerror"); +#ifdef SUPPORTS_NO_GUESS_SCHEME + fprintf(stdout, "no-guess-scheme"); #endif #ifdef SUPPORTS_NORM_IPV4 fprintf(stdout, " normalize-ipv4"); #endif -#ifdef SUPPORTS_IMAP_OPTIONS - if(supports_imap) - fprintf(stdout, " imap-options"); +#ifdef SUPPORTS_PUNYCODE + if(supports_puny) + fprintf(stdout, " punycode"); #endif #ifdef SUPPORTS_PUNY2IDN if(supports_puny) fprintf(stdout, " punycode2idn"); #endif +#ifdef SUPPORTS_URL_STRERROR + fprintf(stdout, " url-strerror"); +#endif +#ifdef SUPPORTS_ALLOW_SPACE + fprintf(stdout, " white-space"); +#endif +#ifdef SUPPORTS_ZONEID + fprintf(stdout, " zone-id"); +#endif fprintf(stdout, "\n"); exit(0); @@ -982,7 +990,7 @@ static const struct var *setone(CURLU *uh, const char *setline, if(conditional) { char *piece; - rc = curl_url_get(uh, v->part, &piece, 0); + rc = curl_url_get(uh, v->part, &piece, CURLU_NO_GUESS_SCHEME); if(!rc) { skip = true; curl_free(piece);