Merge lp:~gue5t/midori/adblock-main-frame-2 into lp:midori

Proposed by gue5t gue5t
Status: Merged
Approved by: Paweł Forysiuk
Approved revision: 7086
Merged at revision: 7090
Proposed branch: lp:~gue5t/midori/adblock-main-frame-2
Merge into: lp:midori
Diff against target: 21 lines (+9/-2)
1 file modified
extensions/adblock/extension.vala (+9/-2)
To merge this branch: bzr merge lp:~gue5t/midori/adblock-main-frame-2
Reviewer Review Type Date Requested Status
Paweł Forysiuk Approve
Review via email: mp+282124@code.launchpad.net

Commit message

Do not block the main webpage of a tab even if it is matched by adblock rules

Description of the change

Compare the provisional data source of the main frame with the URI we're requesting. If they match, and the request came from the main frame, then we know this request is the main page for the frame and should be allowed to pass through.

This was tested with easylist and <http://w3easy.org/templates/a_120x60.b>, which was matched by the rule "@@||w3easy.org/templates/*_120x60.", as well as with <http://www.twotoasts.de/index.php/2014/04/advertisements-and-two-little-kittens> which is blocked by the default adblock extension lists.

To post a comment you must log in.
Revision history for this message
Paweł Forysiuk (tuxator) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'extensions/adblock/extension.vala'
--- extensions/adblock/extension.vala 2015-07-11 16:33:32 +0000
+++ extensions/adblock/extension.vala 2016-01-10 19:19:36 +0000
@@ -182,8 +182,15 @@
182#if !HAVE_WEBKIT2182#if !HAVE_WEBKIT2
183 void resource_requested (WebKit.WebView web_view, WebKit.WebFrame frame,183 void resource_requested (WebKit.WebView web_view, WebKit.WebFrame frame,
184 WebKit.WebResource resource, WebKit.NetworkRequest request, WebKit.NetworkResponse? response) {184 WebKit.WebResource resource, WebKit.NetworkRequest request, WebKit.NetworkResponse? response) {
185185
186 if (request_handled (request.uri, web_view.uri)) {186 WebKit.WebFrame main_frame = web_view.get_main_frame ();
187
188 WebKit.WebDataSource? ds = main_frame.get_provisional_data_source ();
189 WebKit.NetworkRequest? main_frame_request = (ds != null) ? ds.get_request () : null;
190 string? main_frame_uri = (main_frame_request != null) ? main_frame_request.uri : null;
191
192 bool is_main_frame_request = (frame == main_frame) && (request.uri == main_frame_uri);
193 if (!is_main_frame_request && request_handled (request.uri, web_view.uri)) {
187 request.set_uri ("about:blank");194 request.set_uri ("about:blank");
188 }195 }
189 }196 }

Subscribers

People subscribed via source and target branches

to all changes: