Changeset 99138 in webkit
- Timestamp:
- Nov 2, 2011 9:39:32 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r99136 r99138 1 2011-11-02 Adam Barth <abarth@webkit.org> 2 3 Implement allow-popups for iframe@sandbox 4 https://bugs.webkit.org/show_bug.cgi?id=66505 5 6 Reviewed by Eric Seidel. 7 8 Test that the allow-popups directive works as expected. Note: 9 no-popup-from-sandbox.html verifies that we still block popups without 10 the directive. 11 12 * http/tests/security/popup-allowed-by-sandbox-is-sandboxed-control-expected.txt: Added. 13 * http/tests/security/popup-allowed-by-sandbox-is-sandboxed-control.html: Added. 14 * http/tests/security/popup-allowed-by-sandbox-is-sandboxed-expected.txt: Added. 15 * http/tests/security/popup-allowed-by-sandbox-is-sandboxed.html: Added. 16 * http/tests/security/popup-allowed-by-sandbox-when-allowed-expected.txt: Added. 17 * http/tests/security/popup-allowed-by-sandbox-when-allowed.html: Added. 18 1 19 2011-11-02 Sam Weinig <sam@webkit.org> 2 20 -
trunk/Source/WebCore/ChangeLog
r99137 r99138 1 2011-11-02 Adam Barth <abarth@webkit.org> 2 3 Implement allow-popups for iframe@sandbox 4 https://bugs.webkit.org/show_bug.cgi?id=66505 5 6 Reviewed by Eric Seidel. 7 8 There's been some discussion in the HTML working group about adding an 9 allow-popups directive to the iframe sandbox. Microsoft has added it 10 to IE10 platform preview and is fairly adamant about this feature 11 because it's needed by one or their products that's planning to use 12 iframe sandbox. Hixie says he'll add it to the spec once we implement 13 it, so here's our implementation. (See discussion in the W3C linked in 14 the bug for more details.) 15 16 Tests: http/tests/security/popup-allowed-by-sandbox-is-sandboxed-control.html 17 http/tests/security/popup-allowed-by-sandbox-is-sandboxed.html 18 http/tests/security/popup-allowed-by-sandbox-when-allowed.html 19 20 * html/HTMLIFrameElement.cpp: 21 (WebCore::HTMLIFrameElement::parseMappedAttribute): 22 * loader/FrameLoader.cpp: 23 (WebCore::FrameLoader::setOpener): 24 (WebCore::createWindow): 25 * loader/FrameLoader.h: 26 (WebCore::FrameLoader::forceSandboxFlags): 27 * loader/FrameLoaderTypes.h: 28 * loader/PolicyChecker.cpp: 29 (WebCore::PolicyChecker::checkNewWindowPolicy): 30 * page/SecurityOrigin.cpp: 31 (WebCore::SecurityOrigin::parseSandboxPolicy): 32 * page/SecurityOrigin.h: 33 (WebCore::SecurityOrigin::sandboxFlags): 34 * svg/graphics/SVGImage.cpp: 35 (WebCore::SVGImage::dataChanged): 36 1 37 2011-11-02 Sam Weinig <sam@webkit.org> 2 38 -
trunk/Source/WebCore/html/HTMLIFrameElement.cpp
r98300 r99138 33 33 #include "NodeRenderingContext.h" 34 34 #include "RenderIFrame.h" 35 #include "SecurityOrigin.h" 35 36 36 37 namespace WebCore { … … 69 70 } 70 71 71 static SandboxFlags parseSandboxAttribute(Attribute* attribute)72 {73 if (attribute->isNull())74 return SandboxNone;75 76 // Parse the unordered set of unique space-separated tokens.77 SandboxFlags flags = SandboxAll;78 const UChar* characters = attribute->value().characters();79 unsigned length = attribute->value().length();80 unsigned start = 0;81 while (true) {82 while (start < length && isASCIISpace(characters[start]))83 ++start;84 if (start >= length)85 break;86 unsigned end = start + 1;87 while (end < length && !isASCIISpace(characters[end]))88 ++end;89 90 // Turn off the corresponding sandbox flag if it's set as "allowed".91 String sandboxToken = String(characters + start, end - start);92 if (equalIgnoringCase(sandboxToken, "allow-same-origin"))93 flags &= ~SandboxOrigin;94 else if (equalIgnoringCase(sandboxToken, "allow-forms"))95 flags &= ~SandboxForms;96 else if (equalIgnoringCase(sandboxToken, "allow-scripts"))97 flags &= ~SandboxScripts;98 else if (equalIgnoringCase(sandboxToken, "allow-top-navigation"))99 flags &= ~SandboxTopNavigation;100 101 start = end + 1;102 }103 104 return flags;105 }106 107 72 void HTMLIFrameElement::parseMappedAttribute(Attribute* attr) 108 73 { … … 128 93 addCSSLength(attr, CSSPropertyBorderWidth, "0"); 129 94 } else if (attr->name() == sandboxAttr) 130 setSandboxFlags( parseSandboxAttribute(attr));95 setSandboxFlags(attr->isNull() ? SandboxNone : SecurityOrigin::parseSandboxPolicy(attr->value())); 131 96 else 132 97 HTMLFrameElementBase::parseMappedAttribute(attr); -
trunk/Source/WebCore/loader/FrameLoader.cpp
r97716 r99138 946 946 if (opener) 947 947 opener->loader()->m_openedFrames.add(m_frame); 948 948 949 m_opener = opener; 950 951 if (m_opener && !m_frame->tree()->parent()) 952 forceSandboxFlags(m_opener->document()->securityOrigin()->sandboxFlags()); 949 953 950 954 if (m_frame->document()) { … … 3269 3273 3270 3274 // Sandboxed frames cannot open new auxiliary browsing contexts. 3271 if (isDocumentSandboxed(openerFrame, Sandbox Navigation))3275 if (isDocumentSandboxed(openerFrame, SandboxPopups)) 3272 3276 return 0; 3273 3277 -
trunk/Source/WebCore/loader/FrameLoader.h
r95593 r99138 216 216 // The following sandbox flags will be forced, regardless of changes to 217 217 // the sandbox attribute of any parent frames. 218 void setForcedSandboxFlags(SandboxFlags flags) { m_forcedSandboxFlags= flags; m_sandboxFlags |= flags; }218 void forceSandboxFlags(SandboxFlags flags) { m_forcedSandboxFlags |= flags; m_sandboxFlags |= flags; } 219 219 220 220 // Mixed content related functions. -
trunk/Source/WebCore/loader/FrameLoaderTypes.h
r96060 r99138 101 101 SandboxScripts = 1 << 4, 102 102 SandboxTopNavigation = 1 << 5, 103 SandboxPopups = 1 << 6, 103 104 SandboxAll = -1 // Mask with all bits set to 1. 104 105 }; -
trunk/Source/WebCore/loader/PolicyChecker.cpp
r97716 r99138 94 94 const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, void* argument) 95 95 { 96 if (m_frame->document() && m_frame->document()->securityOrigin()->isSandboxed(Sandbox Navigation))96 if (m_frame->document() && m_frame->document()->securityOrigin()->isSandboxed(SandboxPopups)) 97 97 return continueAfterNavigationPolicy(PolicyIgnore); 98 98 -
trunk/Source/WebCore/page/SecurityOrigin.cpp
r98316 r99138 544 544 } 545 545 546 SandboxFlags SecurityOrigin::parseSandboxPolicy(const String& policy) 547 { 548 // Parse the unordered set of unique space-separated tokens. 549 SandboxFlags flags = SandboxAll; 550 const UChar* characters = policy.characters(); 551 unsigned length = policy.length(); 552 unsigned start = 0; 553 while (true) { 554 while (start < length && isASCIISpace(characters[start])) 555 ++start; 556 if (start >= length) 557 break; 558 unsigned end = start + 1; 559 while (end < length && !isASCIISpace(characters[end])) 560 ++end; 561 562 // Turn off the corresponding sandbox flag if it's set as "allowed". 563 String sandboxToken = String(characters + start, end - start); 564 if (equalIgnoringCase(sandboxToken, "allow-same-origin")) 565 flags &= ~SandboxOrigin; 566 else if (equalIgnoringCase(sandboxToken, "allow-forms")) 567 flags &= ~SandboxForms; 568 else if (equalIgnoringCase(sandboxToken, "allow-scripts")) 569 flags &= ~SandboxScripts; 570 else if (equalIgnoringCase(sandboxToken, "allow-top-navigation")) 571 flags &= ~SandboxTopNavigation; 572 else if (equalIgnoringCase(sandboxToken, "allow-popups")) 573 flags &= ~SandboxPopups; 574 575 start = end + 1; 576 } 577 578 return flags; 579 } 580 546 581 void SecurityOrigin::setLocalLoadPolicy(LocalLoadPolicy policy) 547 582 { -
trunk/Source/WebCore/page/SecurityOrigin.h
r98316 r99138 57 57 bool domainWasSetInDOM() const { return m_domainWasSetInDOM; } 58 58 59 // FIXME: This should move to SchemeRegistry. 59 60 static void setDomainRelaxationForbiddenForURLScheme(bool forbidden, const String&); 60 61 static bool isDomainRelaxationForbiddenForURLScheme(const String&); … … 115 116 116 117 bool isSandboxed(SandboxFlags mask) const { return m_sandboxFlags & mask; } 118 SandboxFlags sandboxFlags() const { return m_sandboxFlags; } 117 119 118 120 bool canAccessDatabase() const { return !isUnique(); } … … 178 180 // (and whether it was set) but considering the host. It is used for postMessage. 179 181 bool isSameSchemeHostPort(const SecurityOrigin*) const; 182 183 static SandboxFlags parseSandboxPolicy(const String& policy); 180 184 181 185 static bool shouldHideReferrer(const KURL&, const String& referrer); -
trunk/Source/WebCore/svg/graphics/SVGImage.cpp
r98852 r99138 314 314 frame->init(); 315 315 FrameLoader* loader = frame->loader(); 316 loader-> setForcedSandboxFlags(SandboxAll);316 loader->forceSandboxFlags(SandboxAll); 317 317 318 318 frame->view()->setCanHaveScrollbars(false); // SVG Images will always synthesize a viewBox, if it's not available, and thus never see scrollbars.
Note: See TracChangeset
for help on using the changeset viewer.