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
=== modified file 'data/CMakeLists.txt'
--- data/CMakeLists.txt 2013-12-01 16:01:31 +0000
+++ data/CMakeLists.txt 2014-03-20 20:14:07 +0000
@@ -30,7 +30,14 @@
30 endif ()30 endif ()
31 elseif (${FILE} MATCHES "\\.svg$")31 elseif (${FILE} MATCHES "\\.svg$")
32 string(REPLACE ".svg" "" IMG_ID ${FILE})32 string(REPLACE ".svg" "" IMG_ID ${FILE})
33 SVG2PNG (${IMG_ID} "${CMAKE_INSTALL_DATADIR}/midori/res/")33 string (FIND ${FILE} "/" IS_DIR)
34 if (IS_DIR GREATER -1)
35 string(REPLACE "/" ";" DIR_LIST ${FILE})
36 LIST(GET DIR_LIST 0 S_DIR)
37 SVG2PNG (${IMG_ID} "${CMAKE_INSTALL_DATADIR}/midori/res/${S_DIR}")
38 else ()
39 SVG2PNG (${IMG_ID} "${CMAKE_INSTALL_DATADIR}/midori/res/")
40 endif()
34 # These are being handled in add_executable for the "midori" binary41 # These are being handled in add_executable for the "midori" binary
35 elseif (${FILE} MATCHES "\\.ico$")42 elseif (${FILE} MATCHES "\\.ico$")
36 elseif (${FILE} MATCHES "\\.rc$")43 elseif (${FILE} MATCHES "\\.rc$")
3744
=== modified file 'extensions/adblock/extension.vala'
--- extensions/adblock/extension.vala 2014-03-14 14:36:07 +0000
+++ extensions/adblock/extension.vala 2014-03-20 20:14:07 +0000
@@ -108,7 +108,7 @@
108 browser.remove_tab.connect (tab_removed);108 browser.remove_tab.connect (tab_removed);
109109
110 var toggle_button = status_icon.add_button ();110 var toggle_button = status_icon.add_button ();
111 browser.statusbar.pack_start (toggle_button, false, false, 3);111 browser.statusbar.pack_end (toggle_button, false, false, 3);
112 toggle_button.show ();112 toggle_button.show ();
113 }113 }
114114
115115
=== modified file 'extensions/adblock/subscriptions.vala'
--- extensions/adblock/subscriptions.vala 2014-03-14 21:28:40 +0000
+++ extensions/adblock/subscriptions.vala 2014-03-20 20:14:07 +0000
@@ -160,7 +160,8 @@
160 }160 }
161 }161 }
162162
163 void update_css_hash (string domain, string value) {163 bool css_element_seems_valid (string element) {
164 bool is_valid = true;
164 string[] valid_elements = { "::after", "::before", "a", "abbr", "address", "article", "aside",165 string[] valid_elements = { "::after", "::before", "a", "abbr", "address", "article", "aside",
165 "b", "blockquote", "caption", "center", "cite", "code", "div", "dl", "dt", "dd", "em",166 "b", "blockquote", "caption", "center", "cite", "code", "div", "dl", "dt", "dd", "em",
166 "feed", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6",167 "feed", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6",
@@ -168,15 +169,28 @@
168 "m", "main", "marquee", "menu", "nav", "ol", "option", "p", "pre", "q", "samp", "section",169 "m", "main", "marquee", "menu", "nav", "ol", "option", "p", "pre", "q", "samp", "section",
169 "small", "span", "strong", "summary", "table", "tr", "tbody", "td", "th", "thead", "tt", "ul" };170 "small", "span", "strong", "summary", "table", "tr", "tbody", "td", "th", "thead", "tt", "ul" };
170171
171 if (!value.has_prefix (".") && !value.has_prefix ("#")172 if (!element.has_prefix (".") && !element.has_prefix ("#")
172 && !(value.split("[")[0] in valid_elements))173 && !(element.split("[")[0] in valid_elements))
173 message ("Adblock: Invalid selector: %s", value);174 is_valid = false;
174 string? olddata = element.lookup (domain);175
175 if (olddata != null) {176
176 string newdata = olddata + " , " + value;177 bool debug_selectors = "adblock:css" in (Environment.get_variable ("MIDORI_DEBUG") ?? "");
177 element.insert (domain, newdata);178 if (debug_selectors)
178 } else {179 stdout.printf ("Adblock '%s' %s: %s\n",
179 element.insert (domain, value);180 this.title, is_valid ? "selector" : "INVALID?", element);
181
182 return is_valid;
183 }
184
185 void update_css_hash (string domain, string value) {
186 if (css_element_seems_valid (value)) {
187 string? olddata = element.lookup (domain);
188 if (olddata != null) {
189 string newdata = olddata + " , " + value;
190 element.insert (domain, newdata);
191 } else {
192 element.insert (domain, value);
193 }
180 }194 }
181 }195 }
182196
183197
=== modified file 'midori/midori-app.c'
--- midori/midori-app.c 2014-03-17 02:00:36 +0000
+++ midori/midori-app.c 2014-03-20 20:14:07 +0000
@@ -1254,7 +1254,7 @@
1254midori_debug (const gchar* token)1254midori_debug (const gchar* token)
1255{1255{
1256 static const gchar* debug_token = NULL;1256 static const gchar* debug_token = NULL;
1257 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 ";1257 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 ";
1258 if (debug_token == NULL)1258 if (debug_token == NULL)
1259 {1259 {
1260 gchar* found_token;1260 gchar* found_token;
12611261
=== modified file 'midori/midori-tab.vala'
--- midori/midori-tab.vala 2014-03-05 07:17:45 +0000
+++ midori/midori-tab.vala 2014-03-20 20:14:07 +0000
@@ -128,11 +128,11 @@
128 public void inject_stylesheet (string stylesheet) {128 public void inject_stylesheet (string stylesheet) {
129#if !HAVE_WEBKIT2129#if !HAVE_WEBKIT2
130 var dom = web_view.get_dom_document ();130 var dom = web_view.get_dom_document ();
131 return_if_fail (dom.head != null);
131 try {132 try {
132 var style = dom.create_element ("style");133 var style = dom.create_element ("style");
133 style.set_attribute ("type", "text/css");134 style.set_attribute ("type", "text/css");
134 style.append_child (dom.create_text_node (stylesheet));135 style.append_child (dom.create_text_node (stylesheet));
135 return_if_fail (dom.head != null);
136 dom.head.append_child (style);136 dom.head.append_child (style);
137 }137 }
138 catch (Error error) {138 catch (Error error) {

Subscribers

People subscribed via source and target branches

to all changes: