diff options
author | Narayan Kamath <narayan@google.com> | 2014-10-28 12:41:01 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-10-28 12:41:01 +0000 |
commit | bb23450e9101061e636afb15aaebcfa5ed9724c1 (patch) | |
tree | 162132f55a9fda4546937324842df6209b375169 | |
parent | f7ba96dcf561cc95389d19b81f51828315b4a2e8 (diff) | |
parent | 435edc3fa9abd3f8d324c9dd4279a165051052ba (diff) | |
download | libcore-bb23450e9101061e636afb15aaebcfa5ed9724c1.zip libcore-bb23450e9101061e636afb15aaebcfa5ed9724c1.tar.gz libcore-bb23450e9101061e636afb15aaebcfa5ed9724c1.tar.bz2 |
Merge "Allow "_" in URIs."
-rw-r--r-- | luni/src/main/java/java/net/URI.java | 5 | ||||
-rw-r--r-- | luni/src/test/java/libcore/java/net/URITest.java | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/luni/src/main/java/java/net/URI.java b/luni/src/main/java/java/net/URI.java index f206473..60bb5db 100644 --- a/luni/src/main/java/java/net/URI.java +++ b/luni/src/main/java/java/net/URI.java @@ -571,7 +571,10 @@ public final class URI implements Comparable<URI>, Serializable { private boolean isValidDomainName(String host) { try { - UriCodec.validateSimple(host, "-."); + // The RFCs don't permit underscores in hostnames, but URI has to because + // a certain large website doesn't seem to care about standards and specs. + // See bugs 18023709, 17579865 and 18016625. + UriCodec.validateSimple(host, "_-."); } catch (URISyntaxException e) { return false; } diff --git a/luni/src/test/java/libcore/java/net/URITest.java b/luni/src/test/java/libcore/java/net/URITest.java index 7f4c086..c87433a 100644 --- a/luni/src/test/java/libcore/java/net/URITest.java +++ b/luni/src/test/java/libcore/java/net/URITest.java @@ -702,11 +702,15 @@ public final class URITest extends TestCase { } // http://code.google.com/p/android/issues/detail?id=37577 + // http://b/18023709 + // http://b/17579865 + // http://b/18016625 public void testUnderscore() throws Exception { URI uri = new URI("http://a_b.c.d.net/"); assertEquals("a_b.c.d.net", uri.getAuthority()); - // The RFC's don't permit underscores in hostnames, and neither does URI (unlike URL). - assertNull(uri.getHost()); + // The RFC's don't permit underscores in hostnames, but URI has to because + // a certain large website doesn't seem to care about standards and specs. + assertEquals("a_b.c.d.net", uri.getHost()); } // Adding a new test? Consider adding an equivalent test to URLTest.java |