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
1=== modified file 'extensions/adblock/extension.vala'
2--- extensions/adblock/extension.vala 2015-07-11 16:33:32 +0000
3+++ extensions/adblock/extension.vala 2016-01-10 19:19:36 +0000
4@@ -182,8 +182,15 @@
5 #if !HAVE_WEBKIT2
6 void resource_requested (WebKit.WebView web_view, WebKit.WebFrame frame,
7 WebKit.WebResource resource, WebKit.NetworkRequest request, WebKit.NetworkResponse? response) {
8-
9- if (request_handled (request.uri, web_view.uri)) {
10+
11+ WebKit.WebFrame main_frame = web_view.get_main_frame ();
12+
13+ WebKit.WebDataSource? ds = main_frame.get_provisional_data_source ();
14+ WebKit.NetworkRequest? main_frame_request = (ds != null) ? ds.get_request () : null;
15+ string? main_frame_uri = (main_frame_request != null) ? main_frame_request.uri : null;
16+
17+ bool is_main_frame_request = (frame == main_frame) && (request.uri == main_frame_uri);
18+ if (!is_main_frame_request && request_handled (request.uri, web_view.uri)) {
19 request.set_uri ("about:blank");
20 }
21 }

Subscribers

People subscribed via source and target branches

to all changes: