From 18b742e7c94cbd2684960b7d535e2057c3ef2706 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 29 Dec 2023 17:51:36 +0100 Subject: [PATCH] Remove Brave clean urls --- app/src/main/assets/clean-urls.json | 524 ------------------ .../java/eu/faircode/email/UriHelper.java | 46 +- 2 files changed, 1 insertion(+), 569 deletions(-) delete mode 100644 app/src/main/assets/clean-urls.json diff --git a/app/src/main/assets/clean-urls.json b/app/src/main/assets/clean-urls.json deleted file mode 100644 index 676c0e3110..0000000000 --- a/app/src/main/assets/clean-urls.json +++ /dev/null @@ -1,524 +0,0 @@ -[ - { - "include": [ - "*://*.amazon.ae/*", - "*://*.amazon.ca/*", - "*://*.amazon.cn/*", - "*://*.amazon.co.jp/*", - "*://*.amazon.co.uk/*", - "*://*.amazon.com/*", - "*://*.amazon.com.au/*", - "*://*.amazon.com.be/*", - "*://*.amazon.com.br/*", - "*://*.amazon.com.mx/*", - "*://*.amazon.com.tr/*", - "*://*.amazon.de/*", - "*://*.amazon.eg/*", - "*://*.amazon.es/*", - "*://*.amazon.fr/*", - "*://*.amazon.in/*", - "*://*.amazon.it/*", - "*://*.amazon.nl/*", - "*://*.amazon.pl/*", - "*://*.amazon.sa/*", - "*://*.amazon.se/*", - "*://*.amazon.sg/*" - ], - "exclude": [ - - ], - "params": [ - "content-id", - "linkCode", - "tag", - "crid", - "pd_rd_r", - "pd_rd_w", - "pd_rd_wg", - "pf_rd_i", - "pf_rd_m", - "pf_rd_p", - "pf_rd_r", - "pf_rd_s", - "pf_rd_t", - "qid", - "sprefix" - ] - }, - { - "include": [ - "*://*.bandcamp.com/*" - ], - "exclude": [ - - ], - "params": [ - "from" - ] - }, - { - "include": [ - "*://*.imdb.com/*" - ], - "exclude": [ - - ], - "params": [ - "pf_rd_m", - "pf_rd_p", - "pf_rd_r", - "pf_rd_s", - "pf_rd_t", - "pf_rd_i", - "ref_" - ] - }, - { - "include": [ - "*://www.instagram.com/*" - ], - "exclude": [ - - ], - "params": [ - "igshid", - "ig_rid" - ] - }, - { - "include": [ - "*://*.twitter.com/*" - ], - "exclude": [ - "*://*.twitter.com/i/redirect?*" - ], - "params": [ - "cxt", - "ref_src", - "ref_url", - "s", - "t" - ] - }, - { - "include": [ - "*://hbr.org/*", - "*://techcrunch.com/*" - ], - "exclude": [ - - ], - "params": [ - "tpcc" - ] - }, - { - "include": [ - "*://www.wsj.com/*" - ], - "exclude": [ - - ], - "params": [ - "mod" - ] - }, - { - "include": [ - "*://actionnetwork.org/*" - ], - "exclude": [ - - ], - "params": [ - "source" - ] - }, - { - "include": [ - "*://www.zillow.com/*" - ], - "exclude": [ - - ], - "params": [ - "rtoken" - ] - }, - { - "include": [ - "*://feverup.com/*" - ], - "exclude": [ - - ], - "params": [ - "CAMEFROM" - ] - }, - { - "include": [ - "*://www.linkedin.com/in/*" - ], - "exclude": [ - - ], - "params": [ - "trackingCode", - "original_referer" - ] - }, - { - "include": [ - "*://www.linkedin.com/help/*" - ], - "exclude": [ - - ], - "params": [ - "mcid", - "src", - "trk" - ] - }, - { - "include": [ - "*://youtu.be/?*", - "*://*.youtube.com/watch?*" - ], - "exclude": [ - - ], - "params": [ - "embeds_euri", - "embeds_loader_url_for_pings", - "embeds_origin", - "feature", - "si", - "source_ve_path" - ] - }, - { - "include": [ - "*://medium.com/*" - ], - "exclude": [ - - ], - "params": [ - "source" - ] - }, - { - "include": [ - "*://eprint.iacr.org/*", - "*://hackernoon.com/*", - "*://www.backerkit.com/*", - "*://*.kickstarter.com/*" - ], - "exclude": [ - - ], - "params": [ - "ref" - ] - }, - { - "include": [ - "*://*.tiktok.com/*" - ], - "exclude": [ - - ], - "params": [ - "embed_source", - "refer", - "referer_url", - "referer_video_id" - ] - }, - { - "include": [ - "*://*.bloomberglaw.com/*", - "*://*.bloomberg.com/*" - ], - "exclude": [ - - ], - "params": [ - "trk", - "in_source", - "leadSource", - "srnd" - ] - }, - { - "include": [ - "*://*.aliexpress.com/item/*" - ], - "exclude": [ - - ], - "params": [ - "algo_exp_id", - "pdp_npi", - "curPageLogUid" - ] - }, - { - "include": [ - "*://*/*" - ], - "exclude": [ - "*://app.hive.co/*" - ], - "params": [ - "h_sid", - "h_slt" - ] - }, - { - "include": [ - "*://*.eventbrite.com/*" - ], - "exclude": [ - - ], - "params": [ - "aff", - "can_id", - "email_referrer", - "email_subject", - "link_id", - "source" - ] - }, - { - "include": [ - "*://*.seek.com.au/*", - "*://*.seek.co.nz/*" - ], - "exclude": [ - - ], - "params": [ - "tracking" - ] - }, - { - "include": [ - "*://mailchi.mp/*" - ], - "exclude": [ - - ], - "params": [ - "e" - ] - }, - { - "include": [ - "*://*.songkick.com/*" - ], - "exclude": [ - - ], - "params": [ - "deep_link_campaign", - "deep_link_medium", - "deep_link_source" - ] - }, - { - "include": [ - "*://*.humblebundle.com/*" - ], - "exclude": [ - - ], - "params": [ - "hmb_campaign", - "hmb_medium", - "hmb_source" - ] - }, - { - "include": [ - "*://*/*" - ], - "exclude": [ - - ], - "params": [ - "__hssc", - "__hstc", - "_hsenc", - "_hsmi", - "hsCtaTracking", - "cm_cr", - "cm_me", - "cm_re", - "cm_sp", - "cm_mmc", - "cm_mmca1", - "cm_mmca2", - "cm_mmca3", - "cm_mmca4", - "cm_mmca5", - "cm_mmca6", - "cm_mmca7", - "cm_mmca8", - "cm_mmca9", - "cm_mmca10", - "cm_mmca11", - "cm_mmca12", - "cm_mmca13", - "cm_mmca14", - "cm_mmca15", - "hsa_acc", - "hsa_ad", - "hsa_cam", - "hsa_grp", - "hsa_kw", - "hsa_la", - "hsa_mt", - "hsa_net", - "hsa_ol", - "hsa_src", - "hsa_tgt", - "hsa_ver", - "action_object_map", - "action_ref_map", - "action_type_map", - "fb_action_ids", - "fb_action_types", - "fb_comment_id", - "fb_ref", - "fb_source", - "irclickid", - "irgwc", - "ir_adid", - "ir_campaignid", - "ir_partnerid", - "yadclid", - "yadordid", - "yclid", - "ymclid", - "ysclid", - "cx_click", - "cx_recsOrder", - "cx_recsWidget", - "at_campaign", - "at_campaign_type", - "at_channel", - "at_creation", - "at_custom1", - "at_custom2", - "at_custom3", - "at_custom4", - "at_detail_placement", - "at_emailtype", - "at_format", - "at_format", - "at_general_placement", - "at_identifier", - "at_link", - "at_link_id", - "at_link_origin", - "at_link_type", - "at_medium", - "at_network", - "at_platform", - "at_ptr_name", - "at_recipient_id", - "at_recipient_list", - "at_send_date", - "at_term", - "at_type", - "at_variant", - "brave-campaign-id", - "brave-creative-id", - "brave-creative-set-id", - "ml_subscriber", - "ml_subscriber_hash", - "mc_cid", - "ss_campaign_id", - "ss_campaign_name", - "ss_campaign_sent_date", - "ss_source", - "mtm_campaign", - "mtm_cid", - "mtm_content", - "mtm_group", - "mtm_keyword", - "mtm_kwd", - "mtm_medium", - "mtm_placement", - "mtm_source", - "piwik_campaign", - "piwik_kwd", - "pk_campaign", - "pk_cid", - "pk_content", - "pk_cpn", - "pk_keyword", - "pk_kwd", - "pk_medium", - "pk_source", - "utm_ad", - "utm_affiliate", - "utm_brand", - "utm_campaign", - "utm_campaignid", - "utm_channel", - "utm_cid", - "utm_content", - "utm_creative", - "utm_device", - "utm_emcid", - "utm_emmid", - "utm_id", - "utm_keyword", - "utm_medium", - "utm_name", - "utm_place", - "utm_product", - "utm_pubreferrer", - "utm_reader", - "utm_referrer", - "utm_serial", - "utm_session", - "utm_siteid", - "utm_social", - "utm_social-type", - "utm_source", - "utm_supplier", - "utm_swu", - "utm_term", - "utm_umguk", - "utm_userid", - "utm_viz_id", - "gbraid", - "wbraid", - "gclsrc", - "gclid", - "usqp", - "guccounter", - "guce_referrer", - "guce_referrer_sig", - "ex_cid" - ] - }, - { - "include": [ - "https://dev-pages.bravesoftware.com/clean-urls/*" - ], - "exclude": [ - "https://dev-pages.bravesoftware.com/clean-urls/exempted/*" - ], - "params": [ - "brave_testing1", - "brave_testing2" - ] - } -] diff --git a/app/src/main/java/eu/faircode/email/UriHelper.java b/app/src/main/java/eu/faircode/email/UriHelper.java index 9012aef97c..191402a022 100644 --- a/app/src/main/java/eu/faircode/email/UriHelper.java +++ b/app/src/main/java/eu/faircode/email/UriHelper.java @@ -41,7 +41,6 @@ import java.io.InputStreamReader; import java.net.IDN; import java.net.URLDecoder; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; @@ -419,8 +418,6 @@ public class UriHelper { if (path != null) path = path.toLowerCase(Locale.ROOT); - List clean = getBraveClean(context, url); - boolean first = "www.facebook.com".equals(host); for (String key : url.getQueryParameterNames()) { // https://en.wikipedia.org/wiki/UTM_parameters @@ -434,8 +431,7 @@ public class UriHelper { FACEBOOK_WHITELIST_PATH.contains(path) && !FACEBOOK_WHITELIST_QUERY.contains(lkey)) || ("store.steampowered.com".equals(host) && - "snr".equals(lkey)) || - (clean != null && clean.contains(key))) + "snr".equals(lkey))) changed = true; else if (!TextUtils.isEmpty(key)) for (String value : url.getQueryParameters(key)) { @@ -453,46 +449,6 @@ public class UriHelper { return (changed ? builder.build() : null); } - @Nullable - private static List getBraveClean(Context context, Uri uri) { - // https://github.com/brave/adblock-lists/blob/master/brave-lists/clean-urls.json - try (InputStream is = context.getAssets().open("clean-urls.json")) { - String json = Helper.readStream(is); - JSONArray jclean = new JSONArray(json); - for (int i = 0; i < jclean.length(); i++) { - JSONObject jitem = jclean.getJSONObject(i); - JSONArray jinclude = jitem.getJSONArray("include"); - JSONArray jexclude = jitem.getJSONArray("exclude"); - - boolean include = false; - for (int j = 0; j < jinclude.length(); j++) - if (Pattern.matches(escapeStar(jinclude.getString(j)), uri.toString())) { - include = true; - break; - } - - if (include) - for (int j = 0; j < jexclude.length(); j++) - if (Pattern.matches(escapeStar(jexclude.getString(j)), uri.toString())) { - include = false; - break; - } - - if (include) { - JSONArray jparams = jitem.getJSONArray("params"); - List result = new ArrayList<>(); - for (int j = 0; j < jparams.length(); j++) - result.add(jparams.getString(j)); - return result; - } - } - } catch (Throwable ex) { - Log.e(ex); - } - - return null; - } - @Nullable private static Uri getBraveDebounce(Context context, Uri uri) { // https://github.com/brave/adblock-lists/blob/master/brave-lists/debounce.json