From 131192c35cf92818d6fa1c0170577d94ef1e6de1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Marie?= Date: Fri, 13 Feb 2015 14:02:27 +0100 Subject: [PATCH] hsts: reload only the main frame 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 | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main.c b/src/main.c index ace1449..5438ee5 100644 --- a/src/main.c +++ b/src/main.c @@ -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 -- 2.20.1