urlapi: guess scheme correct even with credentials given

In the "scheme-less" parsing case, we need to strip off credentials
first before we guess scheme based on the host name!

Assisted-by: Jay Satiro
Fixes #4856
Closes #4857
This commit is contained in:
Daniel Stenberg 2020-01-27 17:28:40 +01:00
parent 0b030a5b23
commit d3dc0a07e9
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 46 additions and 32 deletions

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -129,6 +129,14 @@ struct querycase {
};
static struct testcase get_parts_list[] ={
{"user:moo@ftp.example.com/color/#green?no-black",
"ftp | user | moo | [13] | ftp.example.com | [15] | /color/ | [16] | "
"green?no-black",
CURLU_GUESS_SCHEME, 0, CURLUE_OK },
{"ftp.user:moo@example.com/color/#green?no-black",
"http | ftp.user | moo | [13] | example.com | [15] | /color/ | [16] | "
"green?no-black",
CURLU_GUESS_SCHEME, 0, CURLUE_OK },
#ifdef WIN32
{"file:/C:\\programs\\foo",
"file | [11] | [12] | [13] | [14] | [15] | C:\\programs\\foo | [16] | [17]",