| Index: src/org/adblockplus/sbrowser/contentblocker/engine/Subscriptions.java |
| =================================================================== |
| --- a/src/org/adblockplus/sbrowser/contentblocker/engine/Subscriptions.java |
| +++ b/src/org/adblockplus/sbrowser/contentblocker/engine/Subscriptions.java |
| @@ -36,16 +36,19 @@ import android.util.Log; |
| * This class holds all listed subscriptions and manages the subscription |
| * aggregation cache folder. |
| */ |
| final class Subscriptions |
| { |
| private static final String TAG = Subscriptions.class.getSimpleName(); |
| private static final String[] USER_SUBSCRIPTIONS = |
| { Engine.USER_FILTERS_TITLE, Engine.USER_EXCEPTIONS_TITLE }; |
| + private static final String[] UNSUPPORTED_FILTERS_REGEX = { |
| + "^(\\|\\$|\\|\\|\\$|@@\\|\\$|@@\\|\\|\\$).*" // Filters that begin with '|$' , '||$' , '@@|$' or '@@||$' |
| + }; |
| private final HashMap<String, Subscription> subscriptions = new HashMap<String, Subscription>(); |
| private final Engine engine; |
| private final File subscriptionFolder; |
| private final File cacheFolder; |
| private final boolean wasUnitialized; |
| private Subscriptions(final Engine engine, final File appFolder, final File cacheFolder) |
| @@ -181,26 +184,47 @@ final class Subscriptions |
| final BufferedWriter w = new BufferedWriter( |
| new OutputStreamWriter(new FileOutputStream(output), "UTF-8")); |
| try |
| { |
| Log.d(TAG, "Writing " + filters.size() + " filters"); |
| Engine.writeFilterHeaders(w); |
| for (final String filter : filters) |
| { |
| - w.write(filter); |
| - w.write('\n'); |
| + // This is a temporary fix to not write filters that might crash Samsung Internet |
| + // See https://issues.adblockplus.org/ticket/4772 |
| + if (!isFilterUnsupported(filter)) |
|
anton
2017/01/09 09:54:43
it would be better to have positive condition inst
diegocarloslima
2017/01/19 13:16:42
Acknowledged.
|
| + { |
| + w.write(filter); |
| + w.write('\n'); |
| + } |
| + else |
| + { |
| + Log.d(TAG, "Ignoring unsupported filter: " + filter); |
| + } |
| } |
| } |
| finally |
| { |
| w.close(); |
| } |
| } |
| + private static boolean isFilterUnsupported(String filter) |
| + { |
| + for (final String unsupportedFilterRegex : UNSUPPORTED_FILTERS_REGEX) |
| + { |
| + if (filter.matches(unsupportedFilterRegex)) |
| + { |
| + return true; |
| + } |
| + } |
| + return false; |
| + } |
| + |
| public Subscription add(final Subscription sub) |
| { |
| final String id = sub.getId(); |
| if (!this.subscriptions.containsKey(id)) |
| { |
| this.subscriptions.put(id, sub); |
| return sub; |
| } |