fix bug with leading dot in cookie domains

This commit is contained in:
David Rose 2007-06-14 23:55:55 +00:00
parent 5f1b029f42
commit a55c6be5cf

View File

@ -125,11 +125,14 @@ parse_set_cookie(const string &format, const URLSpec &url) {
////////////////////////////////////////////////////////////////////
bool HTTPCookie::
matches_url(const URLSpec &url) const {
if (_domain.empty()) {
return false;
}
string server = url.get_server();
if (server == _domain ||
(server.length() > _domain.length() &&
server.substr(server.length() - _domain.length()) == _domain &&
server[server.length() - _domain.length() - 1] == '.')) {
(_domain[0] == '.' || server[server.length() - _domain.length() - 1] == '.'))) {
// The domain matches.
string path = url.get_path();