Title: [135503] trunk/Source/WebCore
- Revision
- 135503
- Author
- [email protected]
- Date
- 2012-11-22 03:59:08 -0800 (Thu, 22 Nov 2012)
Log Message
Move URL-checking code into Frame
https://bugs.webkit.org/show_bug.cgi?id=103014
Patch by Cosmin Truta <[email protected]> on 2012-11-22
Reviewed by Ojan Vafai.
Move the common URL checking logic from HTMLFrameElementBase::isURLAllowed
and HTMLPlugInImageElement::allowedToLoadFrameURL into Frame::isURLAllowed.
No new tests. Refactoring.
* html/HTMLFrameElementBase.cpp:
(WebCore::HTMLFrameElementBase::isURLAllowed): Call Frame::isURLAllowed.
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::allowedToLoadFrameURL): Call Frame::isURLAllowed.
* page/Frame.cpp:
(WebCore::Frame::isURLAllowed): Added.
* page/Frame.h:
(Frame): Added isURLAllowed.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (135502 => 135503)
--- trunk/Source/WebCore/ChangeLog 2012-11-22 11:31:24 UTC (rev 135502)
+++ trunk/Source/WebCore/ChangeLog 2012-11-22 11:59:08 UTC (rev 135503)
@@ -1,3 +1,24 @@
+2012-11-22 Cosmin Truta <[email protected]>
+
+ Move URL-checking code into Frame
+ https://bugs.webkit.org/show_bug.cgi?id=103014
+
+ Reviewed by Ojan Vafai.
+
+ Move the common URL checking logic from HTMLFrameElementBase::isURLAllowed
+ and HTMLPlugInImageElement::allowedToLoadFrameURL into Frame::isURLAllowed.
+
+ No new tests. Refactoring.
+
+ * html/HTMLFrameElementBase.cpp:
+ (WebCore::HTMLFrameElementBase::isURLAllowed): Call Frame::isURLAllowed.
+ * html/HTMLPlugInImageElement.cpp:
+ (WebCore::HTMLPlugInImageElement::allowedToLoadFrameURL): Call Frame::isURLAllowed.
+ * page/Frame.cpp:
+ (WebCore::Frame::isURLAllowed): Added.
+ * page/Frame.h:
+ (Frame): Added isURLAllowed.
+
2012-11-22 Kentaro Hara <[email protected]>
[V8] Rename toWebCoreStringWithNullOrUndefinedCheck() with toWebCoreStringWithUndefinedOrNullCheck()
Modified: trunk/Source/WebCore/html/HTMLFrameElementBase.cpp (135502 => 135503)
--- trunk/Source/WebCore/html/HTMLFrameElementBase.cpp 2012-11-22 11:31:24 UTC (rev 135502)
+++ trunk/Source/WebCore/html/HTMLFrameElementBase.cpp 2012-11-22 11:59:08 UTC (rev 135503)
@@ -66,22 +66,10 @@
return false;
}
- if (Frame* parentFrame = document()->frame()) {
- if (parentFrame->page()->subframeCount() >= Page::maxNumberOfFrames)
- return false;
- }
+ Frame* parentFrame = document()->frame();
+ if (parentFrame)
+ return parentFrame->isURLAllowed(completeURL);
- // We allow one level of self-reference because some sites depend on that.
- // But we don't allow more than one.
- bool foundSelfReference = false;
- for (Frame* frame = document()->frame(); frame; frame = frame->tree()->parent()) {
- if (equalIgnoringFragmentIdentifier(frame->document()->url(), completeURL)) {
- if (foundSelfReference)
- return false;
- foundSelfReference = true;
- }
- }
-
return true;
}
Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (135502 => 135503)
--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp 2012-11-22 11:31:24 UTC (rev 135502)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp 2012-11-22 11:59:08 UTC (rev 135503)
@@ -88,28 +88,13 @@
// depending on <param> values.
bool HTMLPlugInImageElement::allowedToLoadFrameURL(const String& url)
{
- ASSERT(document());
- ASSERT(document()->frame());
- if (document()->frame()->page()->subframeCount() >= Page::maxNumberOfFrames)
- return false;
-
KURL completeURL = document()->completeURL(url);
-
+
if (contentFrame() && protocolIsJavaScript(completeURL)
&& !document()->securityOrigin()->canAccess(contentDocument()->securityOrigin()))
return false;
-
- // We allow one level of self-reference because some sites depend on that.
- // But we don't allow more than one.
- bool foundSelfReference = false;
- for (Frame* frame = document()->frame(); frame; frame = frame->tree()->parent()) {
- if (equalIgnoringFragmentIdentifier(frame->document()->url(), completeURL)) {
- if (foundSelfReference)
- return false;
- foundSelfReference = true;
- }
- }
- return true;
+
+ return document()->frame()->isURLAllowed(completeURL);
}
// We don't use m_url, or m_serviceType as they may not be the final values
Modified: trunk/Source/WebCore/page/Frame.cpp (135502 => 135503)
--- trunk/Source/WebCore/page/Frame.cpp 2012-11-22 11:31:24 UTC (rev 135502)
+++ trunk/Source/WebCore/page/Frame.cpp 2012-11-22 11:59:08 UTC (rev 135503)
@@ -1017,6 +1017,23 @@
m_page->chrome()->client()->numWheelEventHandlersChanged(count);
}
+bool Frame::isURLAllowed(const KURL& url) const
+{
+ // We allow one level of self-reference because some sites depend on that,
+ // but we don't allow more than one.
+ if (m_page->subframeCount() >= Page::maxNumberOfFrames)
+ return false;
+ bool foundSelfReference = false;
+ for (const Frame* frame = this; frame; frame = frame->tree()->parent()) {
+ if (equalIgnoringFragmentIdentifier(frame->document()->url(), url)) {
+ if (foundSelfReference)
+ return false;
+ foundSelfReference = true;
+ }
+ }
+ return true;
+}
+
#if !PLATFORM(MAC) && !PLATFORM(WIN)
struct ScopedFramePaintingState {
ScopedFramePaintingState(Frame* frame, Node* node)
Modified: trunk/Source/WebCore/page/Frame.h (135502 => 135503)
--- trunk/Source/WebCore/page/Frame.h 2012-11-22 11:31:24 UTC (rev 135502)
+++ trunk/Source/WebCore/page/Frame.h 2012-11-22 11:59:08 UTC (rev 135503)
@@ -202,6 +202,8 @@
// Should only be called on the main frame of a page.
void notifyChromeClientWheelEventHandlerCountChanged() const;
+ bool isURLAllowed(const KURL&) const;
+
// ========
private:
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes