LEFT | RIGHT |
(no file at all) | |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 /** | 35 /** |
36 * This class holds all listed subscriptions and manages the subscription | 36 * This class holds all listed subscriptions and manages the subscription |
37 * aggregation cache folder. | 37 * aggregation cache folder. |
38 */ | 38 */ |
39 final class Subscriptions | 39 final class Subscriptions |
40 { | 40 { |
41 private static final String TAG = Subscriptions.class.getSimpleName(); | 41 private static final String TAG = Subscriptions.class.getSimpleName(); |
42 private static final String[] USER_SUBSCRIPTIONS = | 42 private static final String[] USER_SUBSCRIPTIONS = |
43 { Engine.USER_FILTERS_TITLE, Engine.USER_EXCEPTIONS_TITLE }; | 43 { Engine.USER_FILTERS_TITLE, Engine.USER_EXCEPTIONS_TITLE }; |
44 // Filters that begin with '|$' , '||$' , '@@|$' or '@@||$' | |
45 // See https://issues.adblockplus.org/ticket/4772 | |
46 private static final String UNSUPPORTED_FILTERS_REGEX = "^(\\|\\$|\\|\\|\\$|@
@\\|\\$|@@\\|\\|\\$).*"; | |
47 private final HashMap<String, Subscription> subscriptions = new HashMap<String
, Subscription>(); | 44 private final HashMap<String, Subscription> subscriptions = new HashMap<String
, Subscription>(); |
48 | 45 |
49 private final Engine engine; | 46 private final Engine engine; |
50 private final File subscriptionFolder; | 47 private final File subscriptionFolder; |
51 private final File cacheFolder; | 48 private final File cacheFolder; |
52 private final boolean wasUnitialized; | 49 private final boolean wasUnitialized; |
53 | 50 |
54 private Subscriptions(final Engine engine, final File appFolder, final File ca
cheFolder) | 51 private Subscriptions(final Engine engine, final File appFolder, final File ca
cheFolder) |
55 { | 52 { |
56 this.engine = engine; | 53 this.engine = engine; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 { | 172 { |
176 Log.d(TAG, "Adding filters for '" + s.getId() + "'"); | 173 Log.d(TAG, "Adding filters for '" + s.getId() + "'"); |
177 s.clearFilters(); | 174 s.clearFilters(); |
178 s.deserializeFilters(this.getFiltersFile(s)); | 175 s.deserializeFilters(this.getFiltersFile(s)); |
179 s.getFilters(filters); | 176 s.getFilters(filters); |
180 s.clearFilters(); | 177 s.clearFilters(); |
181 } | 178 } |
182 } | 179 } |
183 | 180 |
184 final BufferedWriter w = new BufferedWriter( | 181 final BufferedWriter w = new BufferedWriter( |
185 new OutputStreamWriter(new FileOutputStream(output), "UTF-8")); | 182 new OutputStreamWriter(new FileOutputStream(output), Engine.CHARSET_UTF_
8)); |
186 try | 183 try |
187 { | 184 { |
188 Log.d(TAG, "Writing " + filters.size() + " filters"); | 185 Log.d(TAG, "Writing " + filters.size() + " filters"); |
189 Engine.writeFilterHeaders(w); | 186 Engine.writeFilterHeaders(w); |
190 for (final String filter : filters) | 187 for (final String filter : filters) |
191 { | 188 { |
192 // This is a temporary fix to not write filters that might crash Samsung
Internet | 189 w.write(filter); |
193 // See https://issues.adblockplus.org/ticket/4772 | 190 w.write('\n'); |
194 if (!filter.matches(UNSUPPORTED_FILTERS_REGEX)) | |
195 { | |
196 w.write(filter); | |
197 w.write('\n'); | |
198 } | |
199 else | |
200 { | |
201 Log.d(TAG, "Ignoring unsupported filter: " + filter); | |
202 } | |
203 } | 191 } |
204 } | 192 } |
205 finally | 193 finally |
206 { | 194 { |
207 w.close(); | 195 w.close(); |
208 } | 196 } |
209 } | 197 } |
210 | 198 |
211 public Subscription add(final Subscription sub) | 199 public Subscription add(final Subscription sub) |
212 { | 200 { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 if (sub != null) | 269 if (sub != null) |
282 { | 270 { |
283 if (sub.updateSubscription(responseCode, text, httpHeaders, this.getMetaFi
le(sub), | 271 if (sub.updateSubscription(responseCode, text, httpHeaders, this.getMetaFi
le(sub), |
284 this.getFiltersFile(sub))) | 272 this.getFiltersFile(sub))) |
285 { | 273 { |
286 this.engine.requestUpdateBroadcast(); | 274 this.engine.requestUpdateBroadcast(); |
287 } | 275 } |
288 } | 276 } |
289 } | 277 } |
290 } | 278 } |
LEFT | RIGHT |