NetworkCookie: set the default path according to RFC 6265
This commit is contained in:
@@ -96,6 +96,7 @@ private:
|
|||||||
void _ExtractNameValuePair(
|
void _ExtractNameValuePair(
|
||||||
const BString& cookieString, int16* index,
|
const BString& cookieString, int16* index,
|
||||||
bool parseField = false);
|
bool parseField = false);
|
||||||
|
void _SetDefaultPathForUrl(const BUrl& url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable BString fRawCookie;
|
mutable BString fRawCookie;
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ BNetworkCookie::ParseCookieStringFromUrl(const BString& string,
|
|||||||
|
|
||||||
// Default values from url
|
// Default values from url
|
||||||
SetDomain(url.Host());
|
SetDomain(url.Host());
|
||||||
SetPath(url.Path());
|
_SetDefaultPathForUrl(url);
|
||||||
|
|
||||||
_ExtractNameValuePair(cookieString, &index);
|
_ExtractNameValuePair(cookieString, &index);
|
||||||
|
|
||||||
@@ -811,3 +811,23 @@ BNetworkCookie::_ExtractNameValuePair(const BString& cookieString,
|
|||||||
else if (name == "version")
|
else if (name == "version")
|
||||||
SetVersion(atoi(value.String()));
|
SetVersion(atoi(value.String()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BNetworkCookie::_SetDefaultPathForUrl(const BUrl& url)
|
||||||
|
{
|
||||||
|
const BString& path = url.Path();
|
||||||
|
if (path.IsEmpty() || path.ByteAt(0) != '/') {
|
||||||
|
SetPath("/");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 index = path.FindLast('/');
|
||||||
|
if (index == 0) {
|
||||||
|
SetPath("/");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BString newPath = path;
|
||||||
|
SetPath(newPath.Truncate(index));
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user