]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Sanitize URLs before updating the URL edit text. https://redmine.stoutner.com/issues/454
authorSoren Stoutner <soren@stoutner.com>
Wed, 17 Jul 2019 00:20:20 +0000 (17:20 -0700)
committerSoren Stoutner <soren@stoutner.com>
Wed, 17 Jul 2019 00:20:20 +0000 (17:20 -0700)
.idea/dictionaries/soren.xml
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
app/src/main/res/values/strings.xml

index 082684678722288322964f46995ec6cf4809a4c9..22e0660732de0186ac18606232f5e0d596edb0fb 100644 (file)
@@ -65,6 +65,7 @@
       <w>fanboy</w>
       <w>fanboys</w>
       <w>favoriteicon</w>
+      <w>fbadid</w>
       <w>fbclid</w>
       <w>fbee</w>
       <w>fdfilter</w>
index ce5ccc126cabdb61ea0a8e8f97f9887a137d000a..5f8d80754bbef87c1b19822b4c5855a5f47eeb16 100644 (file)
@@ -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) {
index 70cb18da98b2f5eff251f919d3130aaff7e08553..45eb5ca53a1a465ea9639004654af87514a08e8d 100644 (file)
         <string name="block_all_third_party_requests_summary">Blocking all third-party requests increases privacy, but it breaks many websites.</string>
     <string name="url_modification">URL Modification</string>
         <string name="google_analytics">Google Analytics</string>
-        <string name="google_analytics_summary">Remove “?utm_” or “&amp;utm_” and anything after it from URLs.</string>
+        <string name="google_analytics_summary">Remove “?utm_” and “&amp;utm_” and anything after them from URLs.</string>
         <string name="facebook_click_ids">Facebook Click IDs</string>
-        <string name="facebook_click_ids_summary">Remove “?fbclid=” or “&amp;fbclid=” and anything after it from URLs.</string>
+        <string name="facebook_click_ids_summary">Remove “?fbclid=”, “&amp;fbclid=”, “?fbadid=”, and “&amp;fbadid=” and anything after them from URLs.</string>
         <string name="twitter_amp_redirects">Twitter AMP redirects</string>
         <string name="twitter_amp_redirects_summary">Remove “?amp=1” and anything after it from URLs.</string>
     <string name="tor">Tor</string>