Merge changes from topic "am-f1eb5cc5-7ac1-4540-b9cf-e0577f9334e7" into oc-dev am: 36c202ed80 am: cf31e066a9

am: f64dcd5bb5

Change-Id: I5980a614656d41f648da5a57c933533705a89c63
This commit is contained in:
Adam Vartanian
2018-02-02 07:05:29 +00:00
committed by android-build-merger
2 changed files with 14 additions and 0 deletions

View File

@@ -720,6 +720,10 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
LOOP: while (end < length) {
switch (uriString.charAt(end)) {
case '/': // Start of path
case '\\':// Start of path
// Per http://url.spec.whatwg.org/#host-state, the \ character
// is treated as if it were a / character when encountered in a
// host
case '?': // Start of query
case '#': // Start of fragment
break LOOP;
@@ -758,6 +762,10 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
case '#': // Start of fragment
return ""; // Empty path.
case '/': // Start of path!
case '\\':// Start of path!
// Per http://url.spec.whatwg.org/#host-state, the \ character
// is treated as if it were a / character when encountered in a
// host
break LOOP;
}
pathStart++;

View File

@@ -192,6 +192,12 @@ public class UriTest extends TestCase {
assertEquals("a:a@example.com:a@example2.com", uri.getAuthority());
assertEquals("example2.com", uri.getHost());
assertEquals(-1, uri.getPort());
assertEquals("/path", uri.getPath());
uri = Uri.parse("http://a.foo.com\\.example.com/path");
assertEquals("a.foo.com", uri.getHost());
assertEquals(-1, uri.getPort());
assertEquals("\\.example.com/path", uri.getPath());
}
@SmallTest