[automerger] Adjust URI host parsing to stop on \ character. am: fa3afbd0e7 am: 97668ae137 am: fddbf1b6b2 am: d3c0db66b9 am: 373cfa75c0 am: bdff04aba3 am: 7341805cac am: 885a2ecf96

Change-Id: Ie23e4a58c906b1afe4e47e915251d44c628c9a72
This commit is contained in:
Android Build Merger (Role)
2018-01-31 11:20:55 +00:00
2 changed files with 14 additions and 0 deletions

View File

@@ -719,6 +719,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;
@@ -757,6 +761,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