From: Soren Stoutner Date: Wed, 17 Jul 2019 00:20:20 +0000 (-0700) Subject: Sanitize URLs before updating the URL edit text. https://redmine.stoutner.com/issues/454 X-Git-Tag: v3.2~7 X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=commitdiff_plain;h=717553f0ca8a835fa8ade69e76b53e7c2a7fdea1 Sanitize URLs before updating the URL edit text. https://redmine.stoutner.com/issues/454 --- diff --git a/.idea/dictionaries/soren.xml b/.idea/dictionaries/soren.xml index 08268467..22e06607 100644 --- a/.idea/dictionaries/soren.xml +++ b/.idea/dictionaries/soren.xml @@ -65,6 +65,7 @@ fanboy fanboys favoriteicon + fbadid fbclid fbee fdfilter diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index ce5ccc12..5f8d8075 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -4419,6 +4419,16 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook if (url.contains("&fbclid=")) { url = url.substring(0, url.indexOf("&fbclid=")); } + + // Remove `?fbadid=`. + if (url.contains("?fbadid=")) { + url = url.substring(0, url.indexOf("?fbadid=")); + } + + // Remove `&fbadid=`. + if (url.contains("&fbadid=")) { + url = url.substring(0, url.indexOf("&fbadid=")); + } } // Sanitize Twitter AMP redirects. @@ -5932,11 +5942,17 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook tabTitleTextView.setText(R.string.new_tab); } } else { // The WebView has loaded a webpage. - // Display the final URL. Getting the URL from the WebView instead of using the one provided by `onPageFinished()` makes websites like YouTube function correctly. - urlEditText.setText(currentUrl); + // Update the URL edit text if it is not currently being edited. + if (!urlEditText.hasFocus()) { + // Sanitize the current URL. This removes unwanted URL elements that were added by redirects, so that they won't be included if the URL is shared. + String sanitizedUrl = sanitizeUrl(currentUrl); + + // Display the final URL. Getting the URL from the WebView instead of using the one provided by `onPageFinished()` makes websites like YouTube function correctly. + urlEditText.setText(sanitizedUrl); - // Apply text highlighting to the URL. - highlightUrlText(); + // Apply text highlighting to the URL. + highlightUrlText(); + } // Only populate the title text view if the tab has been fully created. if (tab != null) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 70cb18da..45eb5ca5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -542,9 +542,9 @@ Blocking all third-party requests increases privacy, but it breaks many websites. URL Modification Google Analytics - Remove “?utm_” or “&utm_” and anything after it from URLs. + Remove “?utm_” and “&utm_” and anything after them from URLs. Facebook Click IDs - Remove “?fbclid=” or “&fbclid=” and anything after it from URLs. + Remove “?fbclid=”, “&fbclid=”, “?fbadid=”, and “&fbadid=” and anything after them from URLs. Twitter AMP redirects Remove “?amp=1” and anything after it from URLs. Tor