Changeset 149866 in webkit
- Timestamp:
- May 10, 2013 4:59:15 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r149865 r149866 1 2013-05-10 Anders Carlsson <andersca@apple.com> 2 3 Begin making SecurityOrigin immutable 4 https://bugs.webkit.org/show_bug.cgi?id=115898 5 6 Reviewed by Andreas Kling. 7 8 Replace SecurityOrigin::setDomainFromDOM and SecurityOrigin::grantUniversalAccess with 9 member functions that return new SecurityOrigin objects. 10 11 * dom/Document.cpp: 12 (WebCore::Document::setDomain): 13 Update the security origin to one returned by copyWithDomainSetFromDOM. 14 15 (WebCore::Document::initSecurityContext): 16 Set the security origin to one returned by copyWithUniversalAccessGranted(). 17 18 * page/SecurityOrigin.cpp: 19 (WebCore::SecurityOrigin::SecurityOrigin): 20 Add a new constructor that takes all the member variables as parameters. This is a little unwieldy at the moment, 21 but all the boolean parameters could be replaced by a bitmask of flags. 22 23 (WebCore::SecurityOrigin::isolatedCopy): 24 Call the new constructor. 25 26 (WebCore::SecurityOrigin::copyWithDomainSetFromDOM): 27 Return a new security origin with m_domainWasSetInDOM set to true and the domain updated. 28 29 (WebCore::SecurityOrigin::copyWithUniversalAccessGranted): 30 Return a new security origin with m_universalAccess set to true. 31 1 32 2013-05-10 Anders Carlsson <andersca@apple.com> 2 33 -
trunk/Source/WebCore/dom/Document.cpp
r149865 r149866 3805 3805 3806 3806 // If the new domain is the same as the old domain, still call 3807 // securityOrigin()-> setDomainForDOM. This will change the3807 // securityOrigin()->copyWithDomainSetFromDOM. This will change the 3808 3808 // security check behavior. For example, if a page loaded on port 8000 3809 3809 // assigns its current domain using document.domain, the page will … … 3811 3811 // have also assigned to access this page. 3812 3812 if (equalIgnoringCase(domain(), newDomain)) { 3813 se curityOrigin()->setDomainFromDOM(newDomain);3813 setSecurityOrigin(securityOrigin()->copyWithDomainSetFromDOM(newDomain)); 3814 3814 return; 3815 3815 } … … 3838 3838 } 3839 3839 3840 se curityOrigin()->setDomainFromDOM(newDomain);3840 setSecurityOrigin(securityOrigin()->copyWithDomainSetFromDOM(newDomain)); 3841 3841 } 3842 3842 … … 4598 4598 // Web security is turned off. We should let this document access every other document. This is used primary by testing 4599 4599 // harnesses for web sites. 4600 se curityOrigin()->grantUniversalAccess();4600 setSecurityOrigin(securityOrigin()->copyWithUniversalAccessGranted()); 4601 4601 } else if (securityOrigin()->isLocal()) { 4602 4602 if (settings->allowUniversalAccessFromFileURLs() || m_frame->loader()->client()->shouldForceUniversalAccessFromLocalURL(m_url)) { 4603 4603 // Some clients want local URLs to have universal access, but that setting is dangerous for other clients. 4604 se curityOrigin()->grantUniversalAccess();4604 setSecurityOrigin(securityOrigin()->copyWithUniversalAccessGranted()); 4605 4605 } else if (!settings->allowFileAccessFromFileURLs()) { 4606 4606 // Some clients want local URLs to have even tighter restrictions by default, and not be able to access other local files. -
trunk/Source/WebCore/page/SecurityOrigin.cpp
r149854 r149866 157 157 } 158 158 159 SecurityOrigin::SecurityOrigin(const S ecurityOrigin* other)160 : m_protocol( other->m_protocol.isolatedCopy())161 , m_host( other->m_host.isolatedCopy())162 , m_domain( other->m_domain.isolatedCopy())163 , m_filePath( other->m_filePath.isolatedCopy())164 , m_port( other->m_port)165 , m_isUnique( other->m_isUnique)166 , m_universalAccess( other->m_universalAccess)167 , m_domainWasSetInDOM( other->m_domainWasSetInDOM)168 , m_canLoadLocalResources( other->m_canLoadLocalResources)169 , m_storageBlockingPolicy( other->m_storageBlockingPolicy)170 , m_enforceFilePathSeparation( other->m_enforceFilePathSeparation)171 , m_needsDatabaseIdentifierQuirkForFiles( other->m_needsDatabaseIdentifierQuirkForFiles)159 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) 160 : m_protocol(protocol) 161 , m_host(host) 162 , m_domain(domain) 163 , m_filePath(filePath) 164 , m_port(port) 165 , m_isUnique(isUnique) 166 , m_universalAccess(universalAccess) 167 , m_domainWasSetInDOM(domainWasSetInDOM) 168 , m_canLoadLocalResources(canLoadLocalResources) 169 , m_storageBlockingPolicy(storageBlockingPolicy) 170 , m_enforceFilePathSeparation(enforceFilePathSeparation) 171 , m_needsDatabaseIdentifierQuirkForFiles(needsDatabaseIdentifierQuirkForFiles) 172 172 { 173 173 } … … 208 208 PassRefPtr<SecurityOrigin> SecurityOrigin::isolatedCopy() const 209 209 { 210 return adoptRef(new SecurityOrigin(this)); 211 } 212 213 void SecurityOrigin::setDomainFromDOM(const String& newDomain) 214 { 215 m_domainWasSetInDOM = true; 216 m_domain = newDomain.lower(); 210 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)); 211 } 212 213 PassRefPtr<SecurityOrigin> SecurityOrigin::copyWithDomainSetFromDOM(const String& newDomain) const 214 { 215 String domain = newDomain.lower(); 216 if (m_domainWasSetInDOM && m_domain == domain) 217 return const_cast<SecurityOrigin*>(this); 218 219 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)); 217 220 } 218 221 … … 435 438 } 436 439 437 void SecurityOrigin::grantUniversalAccess() 438 { 439 m_universalAccess = true; 440 PassRefPtr<SecurityOrigin> SecurityOrigin::copyWithUniversalAccessGranted() const 441 { 442 if (m_universalAccess) 443 return const_cast<SecurityOrigin*>(this); 444 445 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)); 440 446 } 441 447 -
trunk/Source/WebCore/page/SecurityOrigin.h
r149854 r149866 75 75 PassRefPtr<SecurityOrigin> isolatedCopy() const; 76 76 77 // Set the domain property of this security originto newDomain. This77 // Create a new security origin with the domain property set to newDomain. This 78 78 // function does not check whether newDomain is a suffix of the current 79 79 // domain. The caller is responsible for validating newDomain. 80 void setDomainFromDOM(const String& newDomain);80 PassRefPtr<SecurityOrigin> copyWithDomainSetFromDOM(const String& newDomain) const; 81 81 bool domainWasSetInDOM() const { return m_domainWasSetInDOM; } 82 82 … … 138 138 // 139 139 // WARNING: This is an extremely powerful ability. Use with caution! 140 void grantUniversalAccess();140 PassRefPtr<SecurityOrigin> copyWithUniversalAccessGranted() const; 141 141 142 142 void setStorageBlockingPolicy(StorageBlockingPolicy policy) { m_storageBlockingPolicy = policy; } … … 216 216 explicit SecurityOrigin(const KURL&); 217 217 explicit SecurityOrigin(const SecurityOrigin*); 218 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); 218 219 219 220 // FIXME: Rename this function to something more semantic.
Note: See TracChangeset
for help on using the changeset viewer.