@@ -36,6 +36,49 @@ struct url_check url_checks[] = {
3636 {0 , "https://fluentbit.io:1234/" , "https" , "fluentbit.io" , "1234" , "/" },
3737 {0 , "https://fluentbit.io:1234/v" , "https" , "fluentbit.io" , "1234" , "/v" },
3838 {-1 , "://" , NULL , NULL , NULL , NULL },
39+ // IPv6 tests
40+ {0 , "https://[::1]/something" , "https" , "::1" , "443" , "/something" },
41+ {0 , "http://[::1]/something" , "http" , "::1" , "80" , "/something" },
42+ {0 , "https://[::1]" , "https" , "::1" , "443" , "/" },
43+ {0 , "https://[::1]:1234/something" , "https" , "::1" , "1234" , "/something" },
44+ {0 , "http://[::1]:1234" , "http" , "::1" , "1234" , "/" },
45+ {0 , "http://[::1]:1234/" , "http" , "::1" , "1234" , "/" },
46+ {0 , "http://[::1]:1234/v" , "http" , "::1" , "1234" , "/v" },
47+ {0 , "https://[2001:db8::1]" , "https" , "2001:db8::1" , "443" , "/" },
48+ {0 , "https://[2001:db8::1]:1234/something" , "https" , "2001:db8::1" , "1234" , "/something" },
49+ {0 , "http://[2001:0db8:0000:0000:0000:0000:0000:0001]:1234/something" , "http" , "2001:0db8:0000:0000:0000:0000:0000:0001" , "1234" , "/something" },
50+ {0 , "https://[::192.9.5.5]:1234/v" , "https" , "::192.9.5.5" , "1234" , "/v" },
51+ {0 , "https://[::1]/path?query=[value]" , "https" , "::1" , "443" , "/path?query=[value]" },
52+ /* Query string with brackets (no path) */
53+ {0 , "https://example.com?query=[1]" , "https" , "example.com" , "443" , "/?query=[1]" },
54+ {0 , "http://example.com?query=[value]&other=[2]" , "http" , "example.com" , "80" , "/?query=[value]&other=[2]" },
55+ {0 , "https://[::1]?query=[value]" , "https" , "::1" , "443" , "/?query=[value]" },
56+ {0 , "https://[2001:db8::1]:8080?query=[1]" , "https" , "2001:db8::1" , "8080" , "/?query=[1]" },
57+ /* Fragment with brackets */
58+ {0 , "https://example.com#fragment=[1]" , "https" , "example.com" , "443" , "/#fragment=[1]" },
59+ {0 , "https://[::1]#fragment=[value]" , "https" , "::1" , "443" , "/#fragment=[value]" },
60+ /* Query and fragment with brackets */
61+ {0 , "https://example.com?query=[1]#fragment=[2]" , "https" , "example.com" , "443" , "/?query=[1]#fragment=[2]" },
62+ /* Port with query/fragment (non-IPv6) */
63+ {0 , "https://example.com:8080?query=[1]" , "https" , "example.com" , "8080" , "/?query=[1]" },
64+ {0 , "http://example.com:9000#fragment=[1]" , "http" , "example.com" , "9000" , "/#fragment=[1]" },
65+ /* Empty query/fragment */
66+ {0 , "https://example.com?" , "https" , "example.com" , "443" , "/?" },
67+ {0 , "https://example.com#" , "https" , "example.com" , "443" , "/#" },
68+ {0 , "https://[::1]?" , "https" , "::1" , "443" , "/?" },
69+ /* IPv6 edge cases - malformed brackets */
70+ {-1 , "http://[::1:8080/path" , NULL , NULL , NULL , NULL }, /* missing closing bracket */
71+ {-1 , "http://::1]:8080/path" , NULL , NULL , NULL , NULL }, /* missing opening bracket in host */
72+ {-1 , "http://[]:8080/path" , NULL , NULL , NULL , NULL }, /* empty brackets */
73+ {-1 , "http://host]name.com/path" , NULL , NULL , NULL , NULL }, /* closing bracket in hostname without opening */
74+ {-1 , "http://host]name.com?query=1" , NULL , NULL , NULL , NULL }, /* closing bracket in hostname without opening (query) */
75+ /* Colons in query/fragment should not be treated as port separators */
76+ {0 , "https://example.com?q=a:b" , "https" , "example.com" , "443" , "/?q=a:b" },
77+ {0 , "https://example.com/path?time=12:30:45" , "https" , "example.com" , "443" , "/path?time=12:30:45" },
78+ {0 , "http://example.com#section:subsection" , "http" , "example.com" , "80" , "/#section:subsection" },
79+ {0 , "https://example.com?q=a:b#frag:ment" , "https" , "example.com" , "443" , "/?q=a:b#frag:ment" },
80+ {0 , "https://[::1]?time=12:30" , "https" , "::1" , "443" , "/?time=12:30" },
81+ {0 , "http://example.com:8080?q=a:b:c" , "http" , "example.com" , "8080" , "/?q=a:b:c" }
3982};
4083
4184void test_url_split_sds ()
0 commit comments