diff options
author | Grace Kloba <klobag@google.com> | 2009-08-03 17:35:08 -0700 |
---|---|---|
committer | Grace Kloba <klobag@google.com> | 2009-08-03 17:35:08 -0700 |
commit | 8ae277735439940480e1301ff729cee32c2ab72e (patch) | |
tree | 977782fec9efb3c0b13041dceee72737b281676f /core/java/android/webkit/CookieManager.java | |
parent | 7a17cf3418eb0cbd23804f51921b7dd66713ad03 (diff) | |
download | frameworks_base-8ae277735439940480e1301ff729cee32c2ab72e.zip frameworks_base-8ae277735439940480e1301ff729cee32c2ab72e.tar.gz frameworks_base-8ae277735439940480e1301ff729cee32c2ab72e.tar.bz2 |
Fix #2031300. Set only accept unique objects. So we have to assign different
value for each cookie when we add them to the SortedSet.
Diffstat (limited to 'core/java/android/webkit/CookieManager.java')
-rw-r--r-- | core/java/android/webkit/CookieManager.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java index c81c4b6..d188a39 100644 --- a/core/java/android/webkit/CookieManager.java +++ b/core/java/android/webkit/CookieManager.java @@ -197,7 +197,24 @@ public final class CookieManager { private static final class CookieComparator implements Comparator<Cookie> { public int compare(Cookie cookie1, Cookie cookie2) { - return cookie2.path.length() - cookie1.path.length(); + // According to RFC 2109, multiple cookies are ordered in a way such + // that those with more specific Path attributes precede those with + // less specific. Ordering with respect to other attributes (e.g., + // Domain) is unspecified. + // As Set is not modified if the two objects are same, we do want to + // assign different value for each cookie. + int diff = cookie2.path.length() - cookie1.path.length(); + if (diff == 0) { + diff = cookie2.domain.length() - cookie1.domain.length(); + if (diff == 0) { + diff = cookie2.name.hashCode() - cookie1.name.hashCode(); + if (diff == 0) { + Log.w(LOGTAG, "Found two cookies with the same value." + + "cookie1=" + cookie1 + " , cookie2=" + cookie2); + } + } + } + return diff; } } |