From: Aram Sargsyan Date: Wed, 17 Jun 2026 15:43:01 +0000 (+0000) Subject: Include the brackets when parsing a URI with a IPv6 address X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=f85d9f5ef3fe6e005712b04b703062a5cc3fc8f2;p=thirdparty%2Fbind9.git Include the brackets when parsing a URI with a IPv6 address The brackets are not included in the host component of the parsed URL/URI. Change the parser to include the brackets. --- diff --git a/lib/isc/url.c b/lib/isc/url.c index 0a91eeeaa2c..954b571b004 100644 --- a/lib/isc/url.c +++ b/lib/isc/url.c @@ -483,16 +483,15 @@ http_parse_host(const char *buf, isc_url_parser_t *up, int found_at) { up->field_data[ISC_UF_HOST].len++; break; - case s_http_host_v6: - if (s != s_http_host_v6) { - up->field_data[ISC_UF_HOST].off = - (uint16_t)(p - buf); - } + case s_http_host_v6_start: + up->field_data[ISC_UF_HOST].off = (uint16_t)(p - buf); up->field_data[ISC_UF_HOST].len++; break; + case s_http_host_v6: case s_http_host_v6_zone_start: case s_http_host_v6_zone: + case s_http_host_v6_end: up->field_data[ISC_UF_HOST].len++; break; diff --git a/tests/isc/url_test.c b/tests/isc/url_test.c index 827342147af..c0d40a5a907 100644 --- a/tests/isc/url_test.c +++ b/tests/isc/url_test.c @@ -214,18 +214,18 @@ ISC_RUN_TEST_IMPL(parse_addressable) { static const url_testcase_t testcases[] = { /* IPv6 literal hosts: the brackets are stripped from the host. */ - { "http://[::1]/", ISC_R_SUCCESS, "http", "", "::1", "", "/", + { "http://[::1]/", ISC_R_SUCCESS, "http", "", "[::1]", "", "/", "", "" }, { "http://[fe80::200:f8ff:fe21:67cf]/", ISC_R_SUCCESS, "http", - "", "fe80::200:f8ff:fe21:67cf", "", "/", "", "" }, + "", "[fe80::200:f8ff:fe21:67cf]", "", "/", "", "" }, { "http://[2001:db8::7]:8080/path", ISC_R_SUCCESS, "http", "", - "2001:db8::7", "8080", "/path", "", "" }, + "[2001:db8::7]", "8080", "/path", "", "" }, { "ldap://[2001:db8::7]/c=GB?objectClass?one", ISC_R_SUCCESS, - "ldap", "", "2001:db8::7", "", "/c=GB", "objectClass?one", + "ldap", "", "[2001:db8::7]", "", "/c=GB", "objectClass?one", "" }, /* An IPv6 zone identifier is kept verbatim (not decoded). */ { "http://[fe80::1%25en0]/", ISC_R_SUCCESS, "http", "", - "fe80::1%25en0", "", "/", "", "" }, + "[fe80::1%25en0]", "", "/", "", "" }, /* IPv4 host with an explicit port. */ { "telnet://192.0.2.16:80/", ISC_R_SUCCESS, "telnet", "",