Title: [119582] trunk/Source/WebKit/qt
- Revision
- 119582
- Author
- [email protected]
- Date
- 2012-06-06 04:21:43 -0700 (Wed, 06 Jun 2012)
Log Message
[Qt] Qt DRT / WTR should be able to load external resources
https://bugs.webkit.org/show_bug.cgi?id=87326
Reviewed by Hajime Morita.
Allow external resources to be loaded when the main frame's URL is also an external resource.
This change is analogous to r118231 for Mac port and to r119153 Chromium port.
* WebCoreSupport/FrameLoaderClientQt.cpp:
(WebCore::blockRequest):
(WebCore):
(WebCore::isLocalhost):
(WebCore::hostIsUsedBySomeTestsToGenerateError):
(WebCore::FrameLoaderClientQt::dispatchWillSendRequest):
Modified Paths
Property Changed
Diff
Modified: trunk/Source/WebKit/qt/ChangeLog (119581 => 119582)
--- trunk/Source/WebKit/qt/ChangeLog 2012-06-06 10:41:54 UTC (rev 119581)
+++ trunk/Source/WebKit/qt/ChangeLog 2012-06-06 11:21:43 UTC (rev 119582)
@@ -1,3 +1,20 @@
+2012-06-06 Zoltan Horvath <[email protected]>
+
+ [Qt] Qt DRT / WTR should be able to load external resources
+ https://bugs.webkit.org/show_bug.cgi?id=87326
+
+ Reviewed by Hajime Morita.
+
+ Allow external resources to be loaded when the main frame's URL is also an external resource.
+ This change is analogous to r118231 for Mac port and to r119153 Chromium port.
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::blockRequest):
+ (WebCore):
+ (WebCore::isLocalhost):
+ (WebCore::hostIsUsedBySomeTestsToGenerateError):
+ (WebCore::FrameLoaderClientQt::dispatchWillSendRequest):
+
2012-06-05 Max Feil <[email protected]>
[BlackBerry] Conditionally enlarge HTML5 video controls in fullscreen mode
Modified: trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp (119581 => 119582)
--- trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp 2012-06-06 10:41:54 UTC (rev 119581)
+++ trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp 2012-06-06 11:21:43 UTC (rev 119582)
@@ -1023,6 +1023,21 @@
dumpAssignedUrls[identifier] = drtDescriptionSuitableForTestResult(request.url());
}
+static void blockRequest(WebCore::ResourceRequest& request)
+{
+ request.setURL(QUrl());
+}
+
+static bool isLocalhost(const QString& host)
+{
+ return host == QLatin1String("127.0.0.1") || host == QLatin1String("localhost");
+}
+
+static bool hostIsUsedBySomeTestsToGenerateError(const QString& host)
+{
+ return host == QLatin1String("255.255.255.255");
+}
+
void FrameLoaderClientQt::dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest& newRequest, const WebCore::ResourceResponse& redirectResponse)
{
QUrl url = ""
@@ -1034,26 +1049,33 @@
(redirectResponse.isNull()) ? "(null)" : qPrintable(drtDescriptionSuitableForTestResult(redirectResponse)));
if (sendRequestReturnsNull) {
- newRequest.setURL(QUrl());
+ blockRequest(newRequest);
return;
}
if (sendRequestReturnsNullOnRedirect && !redirectResponse.isNull()) {
printf("Returning null for this redirect\n");
- newRequest.setURL(QUrl());
+ blockRequest(newRequest);
return;
}
+ QString host = url.host();
+ QString urlLowerScheme = url.scheme().toLower();
+
if (QWebPagePrivate::drtRun
- && url.isValid()
- && (url.scheme().toLower() == QLatin1String("http") || url.scheme().toLower() == QLatin1String("https"))
- && url.host() != QLatin1String("127.0.0.1")
- && url.host() != QLatin1String("255.255.255.255")
- && url.host().toLower() != QLatin1String("localhost")) {
+ && !host.isEmpty()
+ && (urlLowerScheme == QLatin1String("http") || urlLowerScheme == QLatin1String("https"))) {
- printf("Blocked access to external URL %s\n", qPrintable(drtDescriptionSuitableForTestResult(newRequest.url())));
- newRequest.setURL(QUrl());
- return;
+ QUrl testURL = m_frame->page()->mainFrame()->document()->url();
+ QString testHost = testURL.host();
+
+ if (!isLocalhost(host)
+ && !hostIsUsedBySomeTestsToGenerateError(host)
+ && ((urlLowerScheme != QLatin1String("http") && urlLowerScheme != QLatin1String("https")) || testHost.isEmpty() || isLocalhost(testHost))) {
+ printf("Blocked access to external URL %s\n", qPrintable(drtDescriptionSuitableForTestResult(newRequest.url())));
+ blockRequest(newRequest);
+ return;
+ }
}
for (int i = 0; i < sendRequestClearHeaders.size(); ++i)
Property changes on: trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
___________________________________________________________________
Added: svn:executable
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes