Merge lp:~midori/midori/adblock-buglets into lp:midori

Proposed by Paweł Forysiuk
Status: Merged
Approved by: Cris Dywan
Approved revision: 6609
Merged at revision: 6615
Proposed branch: lp:~midori/midori/adblock-buglets
Merge into: lp:midori
Diff against target: 114 lines (+35/-14)
5 files modified
data/CMakeLists.txt (+8/-1)
extensions/adblock/extension.vala (+1/-1)
extensions/adblock/subscriptions.vala (+24/-10)
midori/midori-app.c (+1/-1)
midori/midori-tab.vala (+1/-1)
To merge this branch: bzr merge lp:~midori/midori/adblock-buglets
Reviewer Review Type Date Requested Status
Cris Dywan Approve
Review via email: mp+211581@code.launchpad.net

Commit message

Small adblock bugfixes

To post a comment you must log in.
lp:~midori/midori/adblock-buglets updated
6608. By Paweł Forysiuk

Properly install generated png files in adblock subfolder

Revision history for this message
Cris Dywan (kalikiana) wrote :

Connecting the selector errors to debug:parse is bad, it's next to impossible to see anything within that cloud of dust.

review: Needs Fixing
lp:~midori/midori/adblock-buglets updated
6609. By Paweł Forysiuk

Add adblock:css debug token for displaying element hider selectors

Revision history for this message
Cris Dywan (kalikiana) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/CMakeLists.txt'
2--- data/CMakeLists.txt 2013-12-01 16:01:31 +0000
3+++ data/CMakeLists.txt 2014-03-20 20:14:07 +0000
4@@ -30,7 +30,14 @@
5 endif ()
6 elseif (${FILE} MATCHES "\\.svg$")
7 string(REPLACE ".svg" "" IMG_ID ${FILE})
8- SVG2PNG (${IMG_ID} "${CMAKE_INSTALL_DATADIR}/midori/res/")
9+ string (FIND ${FILE} "/" IS_DIR)
10+ if (IS_DIR GREATER -1)
11+ string(REPLACE "/" ";" DIR_LIST ${FILE})
12+ LIST(GET DIR_LIST 0 S_DIR)
13+ SVG2PNG (${IMG_ID} "${CMAKE_INSTALL_DATADIR}/midori/res/${S_DIR}")
14+ else ()
15+ SVG2PNG (${IMG_ID} "${CMAKE_INSTALL_DATADIR}/midori/res/")
16+ endif()
17 # These are being handled in add_executable for the "midori" binary
18 elseif (${FILE} MATCHES "\\.ico$")
19 elseif (${FILE} MATCHES "\\.rc$")
20
21=== modified file 'extensions/adblock/extension.vala'
22--- extensions/adblock/extension.vala 2014-03-14 14:36:07 +0000
23+++ extensions/adblock/extension.vala 2014-03-20 20:14:07 +0000
24@@ -108,7 +108,7 @@
25 browser.remove_tab.connect (tab_removed);
26
27 var toggle_button = status_icon.add_button ();
28- browser.statusbar.pack_start (toggle_button, false, false, 3);
29+ browser.statusbar.pack_end (toggle_button, false, false, 3);
30 toggle_button.show ();
31 }
32
33
34=== modified file 'extensions/adblock/subscriptions.vala'
35--- extensions/adblock/subscriptions.vala 2014-03-14 21:28:40 +0000
36+++ extensions/adblock/subscriptions.vala 2014-03-20 20:14:07 +0000
37@@ -160,7 +160,8 @@
38 }
39 }
40
41- void update_css_hash (string domain, string value) {
42+ bool css_element_seems_valid (string element) {
43+ bool is_valid = true;
44 string[] valid_elements = { "::after", "::before", "a", "abbr", "address", "article", "aside",
45 "b", "blockquote", "caption", "center", "cite", "code", "div", "dl", "dt", "dd", "em",
46 "feed", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6",
47@@ -168,15 +169,28 @@
48 "m", "main", "marquee", "menu", "nav", "ol", "option", "p", "pre", "q", "samp", "section",
49 "small", "span", "strong", "summary", "table", "tr", "tbody", "td", "th", "thead", "tt", "ul" };
50
51- if (!value.has_prefix (".") && !value.has_prefix ("#")
52- && !(value.split("[")[0] in valid_elements))
53- message ("Adblock: Invalid selector: %s", value);
54- string? olddata = element.lookup (domain);
55- if (olddata != null) {
56- string newdata = olddata + " , " + value;
57- element.insert (domain, newdata);
58- } else {
59- element.insert (domain, value);
60+ if (!element.has_prefix (".") && !element.has_prefix ("#")
61+ && !(element.split("[")[0] in valid_elements))
62+ is_valid = false;
63+
64+
65+ bool debug_selectors = "adblock:css" in (Environment.get_variable ("MIDORI_DEBUG") ?? "");
66+ if (debug_selectors)
67+ stdout.printf ("Adblock '%s' %s: %s\n",
68+ this.title, is_valid ? "selector" : "INVALID?", element);
69+
70+ return is_valid;
71+ }
72+
73+ void update_css_hash (string domain, string value) {
74+ if (css_element_seems_valid (value)) {
75+ string? olddata = element.lookup (domain);
76+ if (olddata != null) {
77+ string newdata = olddata + " , " + value;
78+ element.insert (domain, newdata);
79+ } else {
80+ element.insert (domain, value);
81+ }
82 }
83 }
84
85
86=== modified file 'midori/midori-app.c'
87--- midori/midori-app.c 2014-03-17 02:00:36 +0000
88+++ midori/midori-app.c 2014-03-20 20:14:07 +0000
89@@ -1254,7 +1254,7 @@
90 midori_debug (const gchar* token)
91 {
92 static const gchar* debug_token = NULL;
93- const gchar* debug_tokens = "adblock:match adblock:parse adblock:time adblock:element startup headers body referer cookies paths hsts unarmed db:bookmarks db:history db:tabby mouse app database ";
94+ const gchar* debug_tokens = "adblock:match adblock:parse adblock:time adblock:element adblock:css startup headers body referer cookies paths hsts unarmed db:bookmarks db:history db:tabby mouse app database ";
95 if (debug_token == NULL)
96 {
97 gchar* found_token;
98
99=== modified file 'midori/midori-tab.vala'
100--- midori/midori-tab.vala 2014-03-05 07:17:45 +0000
101+++ midori/midori-tab.vala 2014-03-20 20:14:07 +0000
102@@ -128,11 +128,11 @@
103 public void inject_stylesheet (string stylesheet) {
104 #if !HAVE_WEBKIT2
105 var dom = web_view.get_dom_document ();
106+ return_if_fail (dom.head != null);
107 try {
108 var style = dom.create_element ("style");
109 style.set_attribute ("type", "text/css");
110 style.append_child (dom.create_text_node (stylesheet));
111- return_if_fail (dom.head != null);
112 dom.head.append_child (style);
113 }
114 catch (Error error) {

Subscribers

People subscribed via source and target branches

to all changes: