Changeset 150916 in webkit
- Timestamp:
- May 29, 2013 11:46:40 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r150912 r150916 1 2013-05-29 Otto Derek Cheung <otcheung@rim.com> 2 3 [BlackBerry] Handle Host-Only cookies 4 https://bugs.webkit.org/show_bug.cgi?id=116969 5 6 PR 338809 7 Reviewed by Rob Buis. 8 Internally Reviewed by Joe Mason. 9 10 Adding support for host-only cookies (cookies with no 11 specified domains). These cookies should only be returned 12 when the host matches the cookie domain exactly. 13 14 Tested using Opera and Browser cookie test suite. Tested 15 that host cookies are being stored in it's own map using 16 Web Inspector. 17 18 * platform/blackberry/CookieManager.cpp: 19 (WebCore::CookieManager::getRawCookies): 20 (WebCore::CookieManager::checkAndTreatCookie): 21 (WebCore::CookieManager::findOrCreateCookieMap): 22 * platform/blackberry/CookieParser.cpp: 23 (WebCore::CookieParser::CookieParser): 24 (WebCore::CookieParser::parseOneCookie): 25 * platform/blackberry/ParsedCookie.h: 26 (WebCore::ParsedCookie::isHostOnly): 27 (ParsedCookie): 28 1 29 2013-05-29 Ryosuke Niwa <rniwa@webkit.org> 2 30 -
trunk/Source/WebCore/platform/blackberry/CookieManager.cpp
r149822 r150916 1 1 /* 2 2 * Copyright (C) 2008, 2009 Julien Chaffraix <julien.chaffraix@gmail.com> 3 * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.3 * Copyright (C) 2010, 2011, 2012, 2013 Research In Motion Limited. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 297 297 currentMap->getAllCookies(&cookieCandidates); 298 298 299 // Get cookies from Host-only cookies 300 if (canonicalIP.empty()) { 301 CookieLog("CookieManager - looking for host-only cookies for host - %s", requestURL.host().utf8().data()); 302 CookieMap* hostMap = currentMap->getSubdomainMap(requestURL.host()); 303 if (hostMap) 304 hostMap->getAllCookies(&cookieCandidates); 305 } 306 299 307 // Get cookies from the valid domain maps 300 308 int i = delimitedHost.size() - 1; … … 423 431 } else { 424 432 ASSERT(curMap); 433 CookieLog("CookieManager - adding cookiemap - %s\n", curMap->getName().utf8().data()); 425 434 addCookieToMap(curMap, candidateCookie, postToBackingStore, filter); 426 435 } … … 549 558 Vector<String> delimitedHost; 550 559 551 // If the domain is an IP address , don't split it.552 if (candidateCookie->domainIsIPAddress() )560 // If the domain is an IP address or is a host-only domain, don't split it. 561 if (candidateCookie->domainIsIPAddress() || candidateCookie->isHostOnly()) 553 562 delimitedHost.append(candidateCookie->domain()); 554 563 else -
trunk/Source/WebCore/platform/blackberry/CookieParser.cpp
r149822 r150916 33 33 #include <wtf/CurrentTime.h> 34 34 #include <wtf/text/CString.h> 35 #include <wtf/text/StringBuilder.h> 35 36 36 37 namespace WebCore { … … 61 62 m_defaultCookieHost = hostDomainCanonical; 62 63 m_defaultDomainIsIPAddress = true; 63 } else 64 m_defaultCookieHost = m_defaultCookieHost.startsWith(".") ? m_defaultCookieHost : "." + m_defaultCookieHost; 64 } 65 65 } 66 66 … … 266 266 LOG_ERROR_AND_RETURN("Invalid cookie attribute %s (domain): it does not contain an embedded dot", cookie.ascii().data()); 267 267 268 // If the domain does not start with a dot, add one for security checks ,268 // If the domain does not start with a dot, add one for security checks and to distinguish it from host-only domains 269 269 // For example: ab.c.com dose not domain match b.c.com; 270 String realDomain = parsedValue[0] == '.' ? parsedValue : "." + parsedValue; 270 StringBuilder parsedValueBuilder; 271 if (parsedValue[0] != '.') 272 parsedValueBuilder.appendLiteral("."); 273 parsedValueBuilder.append(parsedValue); 274 String realDomain = parsedValueBuilder.toString(); 275 276 StringBuilder defaultHostBuilder; 277 defaultHostBuilder.appendLiteral("."); 278 defaultHostBuilder.append(m_defaultCookieHost); 279 String defaultHost = defaultHostBuilder.toString(); 271 280 272 281 // Try to return an canonical ip address if the domain is an ip … … 279 288 if (m_defaultDomainIsIPAddress) { 280 289 String realDomainCanonical = BlackBerry::Platform::getCanonicalIPFormat(realDomain); 281 if (realDomainCanonical.isEmpty() || realDomainCanonical != m_defaultCookieHost)290 if (realDomainCanonical.isEmpty() || realDomainCanonical != defaultHost) 282 291 LOG_ERROR_AND_RETURN("Invalid cookie attribute %s (domain): domain is IP but does not match host's IP", cookie.ascii().data()); 283 292 realDomain = realDomainCanonical; … … 289 298 // a.b.com matches b.com, a.b.com matches .B.com and a.b.com matches .A.b.Com 290 299 // and so on. 291 // We also have to make a special case for IP addresses. If a website tries to set 292 // a cookie to 61.97, that domain is not an IP address and will end with the m_defaultCookieHost 293 if (!m_defaultCookieHost.endsWith(realDomain, false)) 300 if (!defaultHost.endsWith(realDomain, false)) 294 301 LOG_ERROR_AND_RETURN("Invalid cookie attribute %s (domain): it does not domain match the host", cookie.ascii().data()); 302 295 303 // We should check for an embedded dot in the portion of string in the host not in the domain 296 304 // but to match firefox behaviour we do not. -
trunk/Source/WebCore/platform/blackberry/ParsedCookie.h
r145163 r150916 86 86 bool isSession() const { return m_isSession; } 87 87 88 bool isHostOnly() const { return !m_domain.startsWith("."); } 89 88 90 bool hasExpired() const; 89 91 bool isForceExpired() const { return m_isForceExpired; }
Note: See TracChangeset
for help on using the changeset viewer.