From 5e2d3b33d4dc2d9221446c32c2fd6a3d79768406 Mon Sep 17 00:00:00 2001 From: Adam Rice Date: Tue, 29 Oct 2019 23:03:39 -0700 Subject: [PATCH] Support IPv6 literals in KURL::SetHostAndPort KURL::SetHostAndPort would corrupt IPv6 literals because they contain ":" characters. Make it check for "[]" characters and use the first ":" after an IPv6 address as the start of the port number if one is present. Fixed: 1012416 Change-Id: If07a671b48c8c1b24b16883fb9072a86b0de7ebc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1871449 Reviewed-by: Kinuko Yasuda Reviewed-by: Daniel Cheng Commit-Queue: Adam Rice Cr-Commit-Position: refs/heads/master@{#710668} --- url/resources/setters_tests.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/url/resources/setters_tests.json b/url/resources/setters_tests.json index 6b7d19b10164a3..d54335f1badeca 100644 --- a/url/resources/setters_tests.json +++ b/url/resources/setters_tests.json @@ -686,6 +686,17 @@ "port": "2" } }, + { + "comment": "IPv6 literal address with port, crbug.com/1012416", + "href": "http://example.net", + "new_value": "[2001:db8::2]:4002", + "expected": { + "href": "http://[2001:db8::2]:4002/", + "host": "[2001:db8::2]:4002", + "hostname": "[2001:db8::2]", + "port": "4002" + } + }, { "comment": "Default port number is removed", "href": "http://example.net",