Sort cookies by path length (longest first)
* This makes sure the most specific cookies are sent first, matching what other browsers do.
This commit is contained in:
@@ -160,7 +160,16 @@ BNetworkCookieJar::AddCookie(BNetworkCookie* cookie)
|
|||||||
delete cookie;
|
delete cookie;
|
||||||
} else {
|
} else {
|
||||||
TRACE("Add cookie: %s\n", cookie->RawCookie(true).String());
|
TRACE("Add cookie: %s\n", cookie->RawCookie(true).String());
|
||||||
list->AddItem(cookie);
|
// Keep the list sorted by path length (longest first). This makes sure
|
||||||
|
// that cookies for most specific paths are returned first when
|
||||||
|
// iterating the cookie jar.
|
||||||
|
int32 i;
|
||||||
|
for (i = 0; i < list->CountItems(); i++) {
|
||||||
|
BNetworkCookie* current = list->ItemAt(i);
|
||||||
|
if (current->Path().Length() < cookie->Path().Length())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
list->AddItem(cookie, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user