summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-10-29 12:32:16 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-10-29 12:32:16 +0000
commitf9e4afffa4c4067fd8ac6d647acdb70415af4d55 (patch)
treed7646321c3a1552b58bd33d3bb0677a794e0aa0c
parent1bad070037080f316e284d28046572df816e76a6 (diff)
parentbb23450e9101061e636afb15aaebcfa5ed9724c1 (diff)
downloadlibcore-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.java5
-rw-r--r--luni/src/test/java/libcore/java/net/URITest.java8
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