Modified: trunk/Source/WebCore/dom/Document.cpp (149865 => 149866)
--- trunk/Source/WebCore/dom/Document.cpp 2013-05-10 11:18:10 UTC (rev 149865)
+++ trunk/Source/WebCore/dom/Document.cpp 2013-05-10 11:59:15 UTC (rev 149866)
@@ -3804,13 +3804,13 @@
// FIXME: We should add logging indicating why a domain was not allowed.
// If the new domain is the same as the old domain, still call
- // securityOrigin()->setDomainForDOM. This will change the
+ // securityOrigin()->copyWithDomainSetFromDOM. This will change the
// security check behavior. For example, if a page loaded on port 8000
// assigns its current domain using document.domain, the page will
// allow other pages loaded on different ports in the same domain that
// have also assigned to access this page.
if (equalIgnoringCase(domain(), newDomain)) {
- securityOrigin()->setDomainFromDOM(newDomain);
+ setSecurityOrigin(securityOrigin()->copyWithDomainSetFromDOM(newDomain));
return;
}
@@ -3837,7 +3837,7 @@
return;
}
- securityOrigin()->setDomainFromDOM(newDomain);
+ setSecurityOrigin(securityOrigin()->copyWithDomainSetFromDOM(newDomain));
}
// http://www.whatwg.org/specs/web-apps/current-work/#dom-document-lastmodified
@@ -4597,11 +4597,11 @@
if (!settings->webSecurityEnabled()) {
// Web security is turned off. We should let this document access every other document. This is used primary by testing
// harnesses for web sites.
- securityOrigin()->grantUniversalAccess();
+ setSecurityOrigin(securityOrigin()->copyWithUniversalAccessGranted());
} else if (securityOrigin()->isLocal()) {
if (settings->allowUniversalAccessFromFileURLs() || m_frame->loader()->client()->shouldForceUniversalAccessFromLocalURL(m_url)) {
// Some clients want local URLs to have universal access, but that setting is dangerous for other clients.
- securityOrigin()->grantUniversalAccess();
+ setSecurityOrigin(securityOrigin()->copyWithUniversalAccessGranted());
} else if (!settings->allowFileAccessFromFileURLs()) {
// Some clients want local URLs to have even tighter restrictions by default, and not be able to access other local files.
// FIXME 81578: The naming of this is confusing. Files with restricted access to other local files
Modified: trunk/Source/WebCore/page/SecurityOrigin.cpp (149865 => 149866)
--- trunk/Source/WebCore/page/SecurityOrigin.cpp 2013-05-10 11:18:10 UTC (rev 149865)
+++ trunk/Source/WebCore/page/SecurityOrigin.cpp 2013-05-10 11:59:15 UTC (rev 149866)
@@ -156,19 +156,19 @@
{
}
-SecurityOrigin::SecurityOrigin(const SecurityOrigin* other)
- : m_protocol(other->m_protocol.isolatedCopy())
- , m_host(other->m_host.isolatedCopy())
- , m_domain(other->m_domain.isolatedCopy())
- , m_filePath(other->m_filePath.isolatedCopy())
- , m_port(other->m_port)
- , m_isUnique(other->m_isUnique)
- , m_universalAccess(other->m_universalAccess)
- , m_domainWasSetInDOM(other->m_domainWasSetInDOM)
- , m_canLoadLocalResources(other->m_canLoadLocalResources)
- , m_storageBlockingPolicy(other->m_storageBlockingPolicy)
- , m_enforceFilePathSeparation(other->m_enforceFilePathSeparation)
- , m_needsDatabaseIdentifierQuirkForFiles(other->m_needsDatabaseIdentifierQuirkForFiles)
+SecurityOrigin::SecurityOrigin(const String& protocol, const String& host, const String& domain, const String& filePath, unsigned short port, bool isUnique, bool universalAccess, bool domainWasSetInDOM, bool canLoadLocalResources, StorageBlockingPolicy storageBlockingPolicy, bool enforceFilePathSeparation, bool needsDatabaseIdentifierQuirkForFiles)
+ : m_protocol(protocol)
+ , m_host(host)
+ , m_domain(domain)
+ , m_filePath(filePath)
+ , m_port(port)
+ , m_isUnique(isUnique)
+ , m_universalAccess(universalAccess)
+ , m_domainWasSetInDOM(domainWasSetInDOM)
+ , m_canLoadLocalResources(canLoadLocalResources)
+ , m_storageBlockingPolicy(storageBlockingPolicy)
+ , m_enforceFilePathSeparation(enforceFilePathSeparation)
+ , m_needsDatabaseIdentifierQuirkForFiles(needsDatabaseIdentifierQuirkForFiles)
{
}
@@ -207,13 +207,16 @@
PassRefPtr<SecurityOrigin> SecurityOrigin::isolatedCopy() const
{
- return adoptRef(new SecurityOrigin(this));
+ return adoptRef(new SecurityOrigin(m_protocol.isolatedCopy(), m_host.isolatedCopy(), m_domain.isolatedCopy(), m_filePath.isolatedCopy(), m_port, m_isUnique, m_universalAccess, m_domainWasSetInDOM, m_canLoadLocalResources, m_storageBlockingPolicy, m_enforceFilePathSeparation, m_needsDatabaseIdentifierQuirkForFiles));
}
-void SecurityOrigin::setDomainFromDOM(const String& newDomain)
+PassRefPtr<SecurityOrigin> SecurityOrigin::copyWithDomainSetFromDOM(const String& newDomain) const
{
- m_domainWasSetInDOM = true;
- m_domain = newDomain.lower();
+ String domain = newDomain.lower();
+ if (m_domainWasSetInDOM && m_domain == domain)
+ return const_cast<SecurityOrigin*>(this);
+
+ return adoptRef(new SecurityOrigin(m_protocol, m_host, domain, m_filePath, m_port, m_isUnique, m_universalAccess, true, m_canLoadLocalResources, m_storageBlockingPolicy, m_enforceFilePathSeparation, m_needsDatabaseIdentifierQuirkForFiles));
}
bool SecurityOrigin::isSecure(const KURL& url)
@@ -434,9 +437,12 @@
m_canLoadLocalResources = true;
}
-void SecurityOrigin::grantUniversalAccess()
+PassRefPtr<SecurityOrigin> SecurityOrigin::copyWithUniversalAccessGranted() const
{
- m_universalAccess = true;
+ if (m_universalAccess)
+ return const_cast<SecurityOrigin*>(this);
+
+ return adoptRef(new SecurityOrigin(m_protocol, m_host, m_domain, m_filePath, m_port, m_isUnique, true, m_domainWasSetInDOM, m_canLoadLocalResources, m_storageBlockingPolicy, m_enforceFilePathSeparation, m_needsDatabaseIdentifierQuirkForFiles));
}
#if ENABLE(CACHE_PARTITIONING)
Modified: trunk/Source/WebCore/page/SecurityOrigin.h (149865 => 149866)
--- trunk/Source/WebCore/page/SecurityOrigin.h 2013-05-10 11:18:10 UTC (rev 149865)
+++ trunk/Source/WebCore/page/SecurityOrigin.h 2013-05-10 11:59:15 UTC (rev 149866)
@@ -74,10 +74,10 @@
// when marshalling a SecurityOrigin to another thread.
PassRefPtr<SecurityOrigin> isolatedCopy() const;
- // Set the domain property of this security origin to newDomain. This
+ // Create a new security origin with the domain property set to newDomain. This
// function does not check whether newDomain is a suffix of the current
// domain. The caller is responsible for validating newDomain.
- void setDomainFromDOM(const String& newDomain);
+ PassRefPtr<SecurityOrigin> copyWithDomainSetFromDOM(const String& newDomain) const;
bool domainWasSetInDOM() const { return m_domainWasSetInDOM; }
String protocol() const { return m_protocol; }
@@ -137,7 +137,7 @@
// Explicitly grant the ability to access very other SecurityOrigin.
//
// WARNING: This is an extremely powerful ability. Use with caution!
- void grantUniversalAccess();
+ PassRefPtr<SecurityOrigin> copyWithUniversalAccessGranted() const;
void setStorageBlockingPolicy(StorageBlockingPolicy policy) { m_storageBlockingPolicy = policy; }
@@ -215,6 +215,7 @@
SecurityOrigin();
explicit SecurityOrigin(const KURL&);
explicit SecurityOrigin(const SecurityOrigin*);
+ SecurityOrigin(const String& protocol, const String& host, const String& domain, const String& filePath, unsigned short port, bool isUnique, bool universalAccess, bool domainWasSetInDOM, bool canLoadLocalResources, StorageBlockingPolicy, bool enforceFilePathSeparation, bool needsDatabaseIdentifierQuirkForFiles);
// FIXME: Rename this function to something more semantic.
bool passesFileCheck(const SecurityOrigin*) const;