From 8da92ebf9941715d88b58ff1e6011474bc8b400d Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Sun, 30 Dec 2018 10:51:35 -0500 Subject: [PATCH] Test malformed IPv6 addresses I was worried we weren't handling this case correctly. Fortunately we are. Closes: https://github.com/square/okhttp/issues/4451 --- okhttp-tests/src/test/java/okhttp3/HttpUrlTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/okhttp-tests/src/test/java/okhttp3/HttpUrlTest.java b/okhttp-tests/src/test/java/okhttp3/HttpUrlTest.java index 242248d713b3..9e3c0c888efd 100644 --- a/okhttp-tests/src/test/java/okhttp3/HttpUrlTest.java +++ b/okhttp-tests/src/test/java/okhttp3/HttpUrlTest.java @@ -534,6 +534,10 @@ HttpUrl parse(String url) { "Invalid URL host: \"[0:0:0:0:0:1:255.255.255]\""); } + @Test public void hostIpv6Malformed() throws Exception { + assertInvalid("http://[::g]/", "Invalid URL host: \"[::g]\""); + } + @Test public void hostIpv6CanonicalForm() throws Exception { assertEquals("abcd:ef01:2345:6789:abcd:ef01:2345:6789", parse("http://[abcd:ef01:2345:6789:abcd:ef01:2345:6789]/").host());