Bug 200437 fix assertion in GetCookie() p=dwitte@stanford.edu r=mvl sr=darin

This commit is contained in:
neil%parkwaycc.co.uk 2003-04-03 09:17:21 +00:00
Родитель 6b1be6d044
Коммит 98c06851f7
1 изменённых файлов: 10 добавлений и 6 удалений

Просмотреть файл

@ -1325,6 +1325,9 @@ cookie_CheckPrefs(nsIURI *aHostURI,
return nsICookie::STATUS_ACCEPTED; return nsICookie::STATUS_ACCEPTED;
} }
// helper function for COOKIE_GetCookie
PRIVATE inline PRBool ispathdelimiter(char c) { return c == '/' || c == '?' || c == '#' || c == ';'; }
PUBLIC char * PUBLIC char *
COOKIE_GetCookie(nsIURI *aHostURI, COOKIE_GetCookie(nsIURI *aHostURI,
nsIURI *aFirstURI) nsIURI *aFirstURI)
@ -1398,14 +1401,15 @@ COOKIE_GetCookie(nsIURI *aHostURI,
continue; continue;
} }
char pathLastChar = pathFromURI.CharAt(cookiePathLen);
if (pathFromURI.Length() > cookiePathLen && if (pathFromURI.Length() > cookiePathLen &&
pathLastChar != '/' && pathLastChar != '?' && pathLastChar != '#' && pathLastChar != ';') { !ispathdelimiter(pathFromURI.CharAt(cookiePathLen))) {
/* /*
* note that the '?' test above allows a site at host/abc?def to receive a cookie that * |ispathdelimiter| tests four cases: '/', '?', '#', and ';'.
* has a path attribute of abc. This seems strange but at least one major site * '/' is the "standard" case; the '?' test allows a site at host/abc?def
* (citibank, bug 156725) depends on it. The test for # and ; are put in to proactively * to receive a cookie that has a path attribute of abc. this seems
* avoid problems with other sites - these are the only other chars allowed in the path. * strange but at least one major site (citibank, bug 156725) depends
* on it. The test for # and ; are put in to proactively avoid problems
* with other sites - these are the only other chars allowed in the path.
*/ */
continue; continue;
} }