kernelbase: Allow hostnames to contain any characters in UrlGetPart().

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2022-02-14 20:37:07 -06:00 committed by Alexandre Julliard
parent ef64aea701
commit 4ff109c3d6
2 changed files with 14 additions and 14 deletions

View File

@ -77,7 +77,6 @@ struct parsed_url
enum url_scan_type
{
SCHEME,
HOST,
PORT,
USERPASS,
};
@ -4221,14 +4220,6 @@ static const WCHAR * scan_url(const WCHAR *start, DWORD *size, enum url_scan_typ
}
break;
case HOST:
while (isalnum(*start) || *start == '-' || *start == '.' || *start == ' ' || *start == '*')
{
start++;
(*size)++;
}
break;
default:
FIXME("unknown type %d\n", type);
return L"";
@ -4237,6 +4228,15 @@ static const WCHAR * scan_url(const WCHAR *start, DWORD *size, enum url_scan_typ
return start;
}
static const WCHAR *parse_url_element( const WCHAR *url, const WCHAR *separators )
{
const WCHAR *p;
if ((p = wcspbrk( url, separators )))
return p;
return url + wcslen( url );
}
static LONG parse_url(const WCHAR *url, struct parsed_url *pl)
{
const WCHAR *work;
@ -4280,10 +4280,10 @@ static LONG parse_url(const WCHAR *url, struct parsed_url *pl)
}
else goto ErrorExit;
/* now start parsing hostname or hostnumber */
work++;
pl->hostname = work;
work = scan_url(pl->hostname, &pl->hostname_len, HOST);
pl->hostname = work + 1;
work = parse_url_element( pl->hostname, L":/\\?#" );
pl->hostname_len = work - pl->hostname;
if (*work == ':')
{
/* parse port */

View File

@ -655,7 +655,7 @@ static void test_UrlGetPart(void)
{"http://user:pass:q@host", URL_PART_USERNAME, 0, S_OK, "user", .todo_hr = TRUE},
{"http://user:pass:q@host", URL_PART_PASSWORD, 0, S_OK, "pass:q", .todo_hr = TRUE},
{"http://user@host@q", URL_PART_USERNAME, 0, S_OK, "user"},
{"http://user@host@q", URL_PART_HOSTNAME, 0, S_OK, "host@q", .todo_result = TRUE},
{"http://user@host@q", URL_PART_HOSTNAME, 0, S_OK, "host@q"},
{"http:localhost/index.html", URL_PART_HOSTNAME, 0, E_FAIL, .todo_hr = TRUE},
{"http:/localhost/index.html", URL_PART_HOSTNAME, 0, E_FAIL, .todo_hr = TRUE},