OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) |
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
(...skipping 3374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3385 // Additionally, with | 3385 // Additionally, with |
3386 // <iframe src="scheme-has-exception://host"> | 3386 // <iframe src="scheme-has-exception://host"> |
3387 // <iframe src="http://host"></iframe> | 3387 // <iframe src="http://host"></iframe> |
3388 // <iframe sandbox src="http://host"></iframe> | 3388 // <iframe sandbox src="http://host"></iframe> |
3389 // </iframe> | 3389 // </iframe> |
3390 // both inner iframes would fail the check, even though the outermost iframe | 3390 // both inner iframes would fail the check, even though the outermost iframe |
3391 // passes. | 3391 // passes. |
3392 // | 3392 // |
3393 // In all cases, a frame must be potentially trustworthy in addition to | 3393 // In all cases, a frame must be potentially trustworthy in addition to |
3394 // having an exception listed in order for the exception to be granted. | 3394 // having an exception listed in order for the exception to be granted. |
3395 if (SecurityContext::isSandboxed(SandboxOrigin)) { | 3395 if (!isOriginPotentiallyTrustworthy(securityOrigin(), errorMessage)) |
3396 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url()); | 3396 return false; |
3397 if (!isOriginPotentiallyTrustworthy(origin.get(), errorMessage)) | 3397 if (securityOrigin()->bypassSecureContextCheck()) |
3398 return false; | 3398 return true; |
3399 if (SchemeRegistry::schemeShouldBypassSecureContextCheck(origin->protoco l())) | |
3400 return true; | |
3401 } else { | |
3402 if (!isOriginPotentiallyTrustworthy(securityOrigin(), errorMessage)) | |
3403 return false; | |
3404 if (SchemeRegistry::schemeShouldBypassSecureContextCheck(securityOrigin( )->protocol())) | |
3405 return true; | |
3406 } | |
3407 | 3399 |
3408 if (privilegeContextCheck == StandardSecureContextCheck) { | 3400 if (privilegeContextCheck == StandardSecureContextCheck) { |
3409 Document* context = parentDocument(); | 3401 if (!m_frame) |
3410 while (context) { | 3402 return true; |
3411 // Skip to the next ancestor if it's a srcdoc. | 3403 Frame* parent = m_frame->tree().parent(); |
3412 if (!context->isSrcdocDocument()) { | 3404 while (parent) { |
3413 if (context->securityContext().isSandboxed(SandboxOrigin)) { | 3405 if (!isOriginPotentiallyTrustworthy(parent->securityContext()->secur ityOrigin(), errorMessage)) |
3414 // For a sandboxed origin, use the document's URL. | 3406 return false; |
3415 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(conte xt->url()); | 3407 parent = parent->tree().parent(); |
3416 if (!isOriginPotentiallyTrustworthy(origin.get(), errorMessa ge)) | |
3417 return false; | |
3418 } else { | |
3419 if (!isOriginPotentiallyTrustworthy(context->securityOrigin( ), errorMessage)) | |
3420 return false; | |
3421 } | |
3422 } | |
3423 context = context->parentDocument(); | |
3424 } | 3408 } |
3425 } | 3409 } |
3426 return true; | 3410 return true; |
3427 } | 3411 } |
3428 | 3412 |
3429 StyleSheetList* Document::styleSheets() | 3413 StyleSheetList* Document::styleSheets() |
3430 { | 3414 { |
3431 if (!m_styleSheetList) | 3415 if (!m_styleSheetList) |
3432 m_styleSheetList = StyleSheetList::create(this); | 3416 m_styleSheetList = StyleSheetList::create(this); |
3433 return m_styleSheetList.get(); | 3417 return m_styleSheetList.get(); |
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4934 // This can occur via document.implementation.createDocument(). | 4918 // This can occur via document.implementation.createDocument(). |
4935 m_cookieURL = KURL(ParsedURLString, emptyString()); | 4919 m_cookieURL = KURL(ParsedURLString, emptyString()); |
4936 setSecurityOrigin(SecurityOrigin::createUnique()); | 4920 setSecurityOrigin(SecurityOrigin::createUnique()); |
4937 initContentSecurityPolicy(); | 4921 initContentSecurityPolicy(); |
4938 return; | 4922 return; |
4939 } | 4923 } |
4940 | 4924 |
4941 // In the common case, create the security context from the currently | 4925 // In the common case, create the security context from the currently |
4942 // loading URL with a fresh content security policy. | 4926 // loading URL with a fresh content security policy. |
4943 m_cookieURL = m_url; | 4927 m_cookieURL = m_url; |
4928 // Set the origin initially based on the URL. enforceSandboxFlags() | |
4929 // will adjust it to be a unique origin if necessary. | |
dcheng
2016/02/24 22:11:30
"if necessary": does that mean there are combinati
estark
2016/02/24 22:14:51
I might be misunderstanding the question, but the
| |
4930 setSecurityOrigin(SecurityOrigin::create(m_url)); | |
4944 enforceSandboxFlags(initializer.sandboxFlags()); | 4931 enforceSandboxFlags(initializer.sandboxFlags()); |
4945 if (initializer.shouldEnforceStrictMixedContentChecking()) | 4932 if (initializer.shouldEnforceStrictMixedContentChecking()) |
4946 enforceStrictMixedContentChecking(); | 4933 enforceStrictMixedContentChecking(); |
4947 setInsecureRequestsPolicy(initializer.insecureRequestsPolicy()); | 4934 setInsecureRequestsPolicy(initializer.insecureRequestsPolicy()); |
4948 if (initializer.insecureNavigationsToUpgrade()) { | 4935 if (initializer.insecureNavigationsToUpgrade()) { |
4949 for (auto toUpgrade : *initializer.insecureNavigationsToUpgrade()) | 4936 for (auto toUpgrade : *initializer.insecureNavigationsToUpgrade()) |
4950 addInsecureNavigationUpgrade(toUpgrade); | 4937 addInsecureNavigationUpgrade(toUpgrade); |
4951 } | 4938 } |
4952 setSecurityOrigin(isSandboxed(SandboxOrigin) ? SecurityOrigin::createUnique( ) : SecurityOrigin::create(m_url)); | |
4953 | 4939 |
4954 if (importsController()) { | 4940 if (importsController()) { |
4955 // If this document is an HTML import, grab a reference to it's master d ocument's Content | 4941 // If this document is an HTML import, grab a reference to it's master d ocument's Content |
4956 // Security Policy. We don't call 'initContentSecurityPolicy' in this ca se, as we can't | 4942 // Security Policy. We don't call 'initContentSecurityPolicy' in this ca se, as we can't |
4957 // rebind the master document's policy object: its ExecutionContext need s to remain tied | 4943 // rebind the master document's policy object: its ExecutionContext need s to remain tied |
4958 // to the master document. | 4944 // to the master document. |
4959 setContentSecurityPolicy(importsController()->master()->contentSecurityP olicy()); | 4945 setContentSecurityPolicy(importsController()->master()->contentSecurityP olicy()); |
4960 } else { | 4946 } else { |
4961 initContentSecurityPolicy(); | 4947 initContentSecurityPolicy(); |
4962 } | 4948 } |
(...skipping 25 matching lines...) Expand all Loading... | |
4988 // If we do not obtain a meaningful origin from the URL, then we try to | 4974 // If we do not obtain a meaningful origin from the URL, then we try to |
4989 // find one via the frame hierarchy. | 4975 // find one via the frame hierarchy. |
4990 | 4976 |
4991 if (!initializer.owner()) { | 4977 if (!initializer.owner()) { |
4992 didFailToInitializeSecurityOrigin(); | 4978 didFailToInitializeSecurityOrigin(); |
4993 return; | 4979 return; |
4994 } | 4980 } |
4995 | 4981 |
4996 if (isSandboxed(SandboxOrigin)) { | 4982 if (isSandboxed(SandboxOrigin)) { |
4997 // If we're supposed to inherit our security origin from our owner, | 4983 // If we're supposed to inherit our security origin from our owner, |
4998 // but we're also sandboxed, the only thing we inherit is the ability | 4984 // but we're also sandboxed, the only things we inherit are the |
4999 // to load local resources. This lets about:blank iframes in file:// | 4985 // potential trustworthiness of the origin and the ability to |
4986 // load local resources. This lets about:blank iframes in file:// | |
alexmos
2016/02/26 19:21:57
nit: perhaps s/This/The latter/ or something simil
estark
2016/03/01 02:59:26
Done.
| |
5000 // URL documents load images and other resources from the file system. | 4987 // URL documents load images and other resources from the file system. |
4988 if (initializer.owner()->securityOrigin()->isPotentiallyTrustworthy()) | |
4989 securityOrigin()->setIsPotentiallyTrustworthySandboxedOrigin(); | |
5001 if (initializer.owner()->securityOrigin()->canLoadLocalResources()) | 4990 if (initializer.owner()->securityOrigin()->canLoadLocalResources()) |
5002 securityOrigin()->grantLoadLocalResources(); | 4991 securityOrigin()->grantLoadLocalResources(); |
5003 return; | 4992 return; |
5004 } | 4993 } |
5005 | 4994 |
5006 m_cookieURL = initializer.owner()->cookieURL(); | 4995 m_cookieURL = initializer.owner()->cookieURL(); |
5007 // We alias the SecurityOrigins to match Firefox, see Bug 15313 | 4996 // We alias the SecurityOrigins to match Firefox, see Bug 15313 |
5008 // https://bugs.webkit.org/show_bug.cgi?id=15313 | 4997 // https://bugs.webkit.org/show_bug.cgi?id=15313 |
5009 setSecurityOrigin(initializer.owner()->securityOrigin()); | 4998 setSecurityOrigin(initializer.owner()->securityOrigin()); |
5010 } | 4999 } |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5994 #ifndef NDEBUG | 5983 #ifndef NDEBUG |
5995 using namespace blink; | 5984 using namespace blink; |
5996 void showLiveDocumentInstances() | 5985 void showLiveDocumentInstances() |
5997 { | 5986 { |
5998 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5987 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
5999 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5988 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
6000 for (Document* document : set) | 5989 for (Document* document : set) |
6001 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); | 5990 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); |
6002 } | 5991 } |
6003 #endif | 5992 #endif |
OLD | NEW |