| OLD | NEW | 
|---|
| 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 '@@||$' need to be removed | 
|  | 45   // See https://issues.adblockplus.org/ticket/4772 | 
|  | 46   private static final String UNSUPPORTED_FILTERS_REGEX =  "^(\\|\\$|\\|\\|\\$|@
     @\\|\\$|@@\\|\\|\\$).*"; | 
| 44   private final HashMap<String, Subscription> subscriptions = new HashMap<String
     , Subscription>(); | 47   private final HashMap<String, Subscription> subscriptions = new HashMap<String
     , Subscription>(); | 
| 45 | 48 | 
| 46   private final Engine engine; | 49   private final Engine engine; | 
| 47   private final File subscriptionFolder; | 50   private final File subscriptionFolder; | 
| 48   private final File cacheFolder; | 51   private final File cacheFolder; | 
| 49   private final boolean wasUnitialized; | 52   private final boolean wasUnitialized; | 
| 50 | 53 | 
| 51   private Subscriptions(final Engine engine, final File appFolder, final File ca
     cheFolder) | 54   private Subscriptions(final Engine engine, final File appFolder, final File ca
     cheFolder) | 
| 52   { | 55   { | 
| 53     this.engine = engine; | 56     this.engine = engine; | 
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 179     } | 182     } | 
| 180 | 183 | 
| 181     final BufferedWriter w = new BufferedWriter( | 184     final BufferedWriter w = new BufferedWriter( | 
| 182         new OutputStreamWriter(new FileOutputStream(output), "UTF-8")); | 185         new OutputStreamWriter(new FileOutputStream(output), "UTF-8")); | 
| 183     try | 186     try | 
| 184     { | 187     { | 
| 185       Log.d(TAG, "Writing " + filters.size() + " filters"); | 188       Log.d(TAG, "Writing " + filters.size() + " filters"); | 
| 186       Engine.writeFilterHeaders(w); | 189       Engine.writeFilterHeaders(w); | 
| 187       for (final String filter : filters) | 190       for (final String filter : filters) | 
| 188       { | 191       { | 
| 189         w.write(filter); | 192         // This is a temporary fix to not write filters that might crash Samsung
      Internet | 
| 190         w.write('\n'); | 193         // See https://issues.adblockplus.org/ticket/4772 | 
|  | 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         } | 
| 191       } | 203       } | 
| 192     } | 204     } | 
| 193     finally | 205     finally | 
| 194     { | 206     { | 
| 195       w.close(); | 207       w.close(); | 
| 196     } | 208     } | 
| 197   } | 209   } | 
| 198 | 210 | 
| 199   public Subscription add(final Subscription sub) | 211   public Subscription add(final Subscription sub) | 
| 200   { | 212   { | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 269     if (sub != null) | 281     if (sub != null) | 
| 270     { | 282     { | 
| 271       if (sub.updateSubscription(responseCode, text, httpHeaders, this.getMetaFi
     le(sub), | 283       if (sub.updateSubscription(responseCode, text, httpHeaders, this.getMetaFi
     le(sub), | 
| 272           this.getFiltersFile(sub))) | 284           this.getFiltersFile(sub))) | 
| 273       { | 285       { | 
| 274         this.engine.requestUpdateBroadcast(); | 286         this.engine.requestUpdateBroadcast(); | 
| 275       } | 287       } | 
| 276     } | 288     } | 
| 277   } | 289   } | 
| 278 } | 290 } | 
| OLD | NEW | 
|---|