OSDN Git Service

Advance encodedKeySearchIndex if encodedKey matches a suffix of a parameter.
authorKeith Ito <kito@google.com>
Sun, 21 Mar 2010 21:31:33 +0000 (14:31 -0700)
committerKeith Ito <kito@google.com>
Sun, 21 Mar 2010 21:41:20 +0000 (14:41 -0700)
Bug: 2524610
Change-Id: I51bbf8248133b61825d2ae14afe175cb4d0413b8

core/java/android/net/Uri.java
core/tests/coretests/src/android/net/UriTest.java

index f2ea539..eca4569 100644 (file)
@@ -1598,6 +1598,8 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
                     end = query.length();
                 }
                 return decode(query.substring(equalsIndex + 1, end));
+            } else {
+                encodedKeySearchIndex = equalsIndex + 1;
             }
         }
         return null;
index ad71fcb..095ee13 100644 (file)
@@ -574,5 +574,13 @@ public class UriTest extends TestCase {
             .appendQueryParameter("key", "y z")
             .build();
         assertEquals("y z", uri.getQueryParameter("key"));
+
+        // key is a substring of parameters, but not present
+        uri = Uri.parse("http://test/").buildUpon()
+            .appendQueryParameter("akeyb", "a b")
+            .appendQueryParameter("keya", "c d")
+            .appendQueryParameter("bkey", "e f")
+            .build();
+        assertNull(uri.getQueryParameter("key"));
     }
 }