]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Include the brackets when parsing a URI with a IPv6 address 12266/head
authorAram Sargsyan <aram@isc.org>
Wed, 17 Jun 2026 15:43:01 +0000 (15:43 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Tue, 7 Jul 2026 11:23:16 +0000 (11:23 +0000)
The brackets are not included in the host component of the parsed
URL/URI. Change the parser to include the brackets.

lib/isc/url.c
tests/isc/url_test.c

index 0a91eeeaa2ceb4859d2143112b129dd94ada6268..954b571b0040201e69d28ce7b4e6f0b94dcb3fc8 100644 (file)
@@ -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;
 
index 827342147af32b8e81680c65165ee902f96a2fb8..c0d40a5a90721d7d28477eec5882287ede84c3e9 100644 (file)
@@ -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", "",