hsts: reload only the main frame
authorSébastien Marie <semarie@users.noreply.github.com>
Fri, 13 Feb 2015 13:02:27 +0000 (14:02 +0100)
committerSébastien Marie <semarie@users.noreply.github.com>
Fri, 13 Feb 2015 13:06:50 +0000 (14:06 +0100)
HSTS in done using requeueing. But due to a bug in webkit, a reload of
the frame could be required in order to display the redirected URI (and
not the original one).

The patch force this reload only for the mainframe (where the correct
URI is need), and not for the subframe (where the HSTS stuff is done by
requeueing).

Original idea from @fanglingsu

src/main.c

index ace1449..5438ee5 100644 (file)
@@ -1244,15 +1244,20 @@ static gboolean navigation_decision_requested_cb(WebKitWebView *view,
     char *uri;
     SoupMessage *msg = webkit_network_request_get_message(request);
 
-    /* change uri for known and valid hsts hosts */
-    uri = hsts_get_changed_uri(vb.session, msg);
-    if (uri) {
-        webkit_web_frame_load_uri(frame, uri);
-        webkit_web_policy_decision_ignore(policy);
-
-        g_free(uri);
-        /* mark the request as handled */
-        return true;
+    /*
+     * manually reload the page for HSTS only when it occurs in
+     * the main-frame. the others cases are covered by requeueing.
+     */
+    if ( webkit_web_view_get_main_frame(view) == frame ) {
+        uri = hsts_get_changed_uri(vb.session, msg);
+        if (uri) {
+            webkit_web_frame_load_uri(frame, uri);
+            webkit_web_policy_decision_ignore(policy);
+
+            g_free(uri);
+            /* mark the request as handled */
+            return true;
+        }
     }
 #endif