diff options
author | Narayan Kamath <narayan@google.com> | 2014-10-29 12:32:16 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-10-29 12:32:16 +0000 |
commit | f9e4afffa4c4067fd8ac6d647acdb70415af4d55 (patch) | |
tree | d7646321c3a1552b58bd33d3bb0677a794e0aa0c | |
parent | 1bad070037080f316e284d28046572df816e76a6 (diff) | |
parent | bb23450e9101061e636afb15aaebcfa5ed9724c1 (diff) | |
download | libcore-f9e4afffa4c4067fd8ac6d647acdb70415af4d55.zip libcore-f9e4afffa4c4067fd8ac6d647acdb70415af4d55.tar.gz libcore-f9e4afffa4c4067fd8ac6d647acdb70415af4d55.tar.bz2 |
am bb23450e: Merge "Allow "_" in URIs."
* commit 'bb23450e9101061e636afb15aaebcfa5ed9724c1':
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 |