From e59f99e8ba2f66916186c13dabea9686e1b6f70f Mon Sep 17 00:00:00 2001 From: Soren Stoutner <soren@stoutner.com> Date: Wed, 4 Jan 2017 11:03:34 -0700 Subject: [PATCH] Fix a crash when a resource request has a null host and ad blocking is enabled. Fixes https://redmine.stoutner.com/issues/80. --- app/src/main/assets/de/about_changelog.html | 2 +- app/src/main/assets/en/about_changelog.html | 2 +- app/src/main/assets/es/about_changelog.html | 4 ++-- .../activities/MainWebView.java | 21 ++++++++++--------- app/src/main/res/values-es/strings.xml | 2 -- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/src/main/assets/de/about_changelog.html b/app/src/main/assets/de/about_changelog.html index 33920356..54a413c3 100644 --- a/app/src/main/assets/de/about_changelog.html +++ b/app/src/main/assets/de/about_changelog.html @@ -33,7 +33,7 @@ <body> <h3>1.14 (version code 16)</h3> -<p>26 December 2016 - minimum API 19, target API 25</p> +<p><a href="https://git.stoutner.com/?p=PrivacyBrowser.git;a=commitdiff;h=6d3d23ab62cfdd6ef142dbdb764a6bac8fc38ce1">26 December 2016</a> - minimum API 19, target API 25</p> <ul> <li>Implement <a href="https://redmine.stoutner.com/issues/31">ad blocking</a>.</li> <li>Change the default user agent to PrivacyBrowser/1.0 <a href="https://git.stoutner.com/?p=PrivacyBrowser.git;a=commitdiff;h=7f0fda47dbd040262a8149e1e6d27f7abe9043ea">for real this time</a>.</li> diff --git a/app/src/main/assets/en/about_changelog.html b/app/src/main/assets/en/about_changelog.html index 6ab68f3d..322f8e00 100644 --- a/app/src/main/assets/en/about_changelog.html +++ b/app/src/main/assets/en/about_changelog.html @@ -28,7 +28,7 @@ <body> <h3>1.14 (version code 16)</h3> -<p>26 December 2016 - minimum API 19, target API 25</p> +<p><a href="https://git.stoutner.com/?p=PrivacyBrowser.git;a=commitdiff;h=6d3d23ab62cfdd6ef142dbdb764a6bac8fc38ce1">26 December 2016</a> - minimum API 19, target API 25</p> <ul> <li>Implement <a href="https://redmine.stoutner.com/issues/31">ad blocking</a>.</li> <li>Change the default user agent to PrivacyBrowser/1.0 <a href="https://git.stoutner.com/?p=PrivacyBrowser.git;a=commitdiff;h=7f0fda47dbd040262a8149e1e6d27f7abe9043ea">for real this time</a>.</li> diff --git a/app/src/main/assets/es/about_changelog.html b/app/src/main/assets/es/about_changelog.html index 0cd9a8f7..a5ac401d 100644 --- a/app/src/main/assets/es/about_changelog.html +++ b/app/src/main/assets/es/about_changelog.html @@ -28,7 +28,7 @@ <body> <h3>1.14 (código de versión 16)</h3> -<p>26 de diciembre de 2016 - API mínimo 19, API dirigido 25</p> +<p><a href="https://git.stoutner.com/?p=PrivacyBrowser.git;a=commitdiff;h=6d3d23ab62cfdd6ef142dbdb764a6bac8fc38ce1">26 de diciembre de 2016</a> - API mínimo 19, API dirigido 25</p> <ul> <li>Incluir un <a href="https://redmine.stoutner.com/issues/31">bloqueador de anuncios</a>.</li> <li>Cambiar el agente de usuario por defecto a PrivacyBrowser/1.0 <a href="https://git.stoutner.com/?p=PrivacyBrowser.git;a=commitdiff;h=7f0fda47dbd040262a8149e1e6d27f7abe9043ea">de verdad esta vez</a>.</li> @@ -36,7 +36,7 @@ <li>Añadir la opción de <a href="https://redmine.stoutner.com/issues/75">habilitar pantalla completa</a> y poner <a href="https://git.stoutner.com/?p=PrivacyBrowser.git;a=blobdiff;f=app/src/main/res/xml/preferences.xml;h=cdda87e7c2eaa0cabdb6a1a77ffca1124e9423e1;hp=8ed81b84aab687621a0f08921c4f6165392d59d2;hb=743982f883eab347e4029f8a3be760f780b14da1;hpb=7f0fda47dbd040262a8149e1e6d27f7abe9043ea">un defecto de falso</a>.</li> <li>Arreglar un error que a veces cambió <a href="https://redmine.stoutner.com/issues/74">la barra de navegación gris en modo de pantalla completa</a> al cambiar entre aplicaciones.</li> <li>Aumentar el <a href="https://git.stoutner.com/?p=PrivacyBrowser.git;a=commitdiff;h=5c6db7b33577612ff7f120b30fb98cab8afa591f">API dirigido a 25</a>.</li> - <li>Actualizar la <a href="https://git.stoutner.com/?p=PrivacyBrowser.git;a=blobdiff;f=app/src/main/res/values-es/strings.xml;h=83c162b389a075effb68c7ce41cd03482c7c8bce;hp=ff79b6a9f30dbe71a0a076cfcfdc0df834ebb792;hb=2c8e83a7d1a044a5186020ac17d3cefb22b7f330;hpb=e9ed376cc7890f1d1f2e370e2e63f19dcfd1859d">traducción</a> <a href="https://git.stoutner.com/?p=PrivacyBrowser.git;a=blob;f=app/src/main/assets/es/about_permissions.html;h=eab82ba8ee104e6a71776a557366f70660d28711;hb=2c8e83a7d1a044a5186020ac17d3cefb22b7f330">parcial</a> <a href="https://git.stoutner.com/?p=PrivacyBrowser.git;a=blobdiff;f=app/src/main/assets/es/about_changelog.html;h=ffb0e4895c0323ae4ee6ca11aab775b318a1b9ef;hp=f810cccc58ee840eb2704bcf81c9e3387d29ff2c;hb=c3ec2515bf9a49d4561efc47f5d21106f15cb286;hpb=2c8e83a7d1a044a5186020ac17d3cefb22b7f330">al español</a>.</li> + <li>Actualizar la <a href="https://git.stoutner.com/?p=PrivacyBrowser.git;a=blobdiff;f=app/src/main/res/values-es/strings.xml;h=83c162b389a075effb68c7ce41cd03482c7c8bce;hp=ff79b6a9f30dbe71a0a076cfcfdc0df834ebb792;hb=2c8e83a7d1a044a5186020ac17d3cefb22b7f330;hpb=e9ed376cc7890f1d1f2e370e2e63f19dcfd1859d">traducción</a> <a href="https://git.stoutner.com/?p=PrivacyBrowser.git;a=blob;f=app/src/main/assets/es/about_permissions.html;h=eab82ba8ee104e6a71776a557366f70660d28711;hb=2c8e83a7d1a044a5186020ac17d3cefb22b7f330">parcial</a> <a href="https://git.stoutner.com/?p=PrivacyBrowser.git;a=blobdiff;f=app/src/main/assets/es/about_changelog.html;h=ffb0e4895c0323ae4ee6ca11aab775b318a1b9ef;hp=f810cccc58ee840eb2704bcf81c9e3387d29ff2c;hb=c3ec2515bf9a49d4561efc47f5d21106f15cb286;hpb=2c8e83a7d1a044a5186020ac17d3cefb22b7f330">de español</a>.</li> </ul> <h3>1.13 (código de versión 15)</h3> diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebView.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebView.java index 000cfad6..2e5503b6 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebView.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebView.java @@ -1,5 +1,5 @@ /** - * Copyright 2015-2016 Soren Stoutner <soren@stoutner.com>. + * Copyright 2015-2017 Soren Stoutner <soren@stoutner.com>. * * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>. * @@ -127,7 +127,6 @@ public class MainWebView extends AppCompatActivity implements NavigationView.OnN public static SslCertificate sslCertificate; - // `drawerLayout` is used in `onCreate()`, `onNewIntent()`, and `onBackPressed()`. private DrawerLayout drawerLayout; @@ -529,14 +528,16 @@ public class MainWebView extends AppCompatActivity implements NavigationView.OnN // Create a variable to track if this is an ad server. boolean requestHostIsAdServer = false; - // Check all the subdomains of `requestHost`. - while (requestHost.contains(".")) { - if (adServersSet.contains(requestHost)) { - requestHostIsAdServer = true; - } + // Check all the subdomains of `requestHost` if it is not null. + if (requestHost != null) { + while (requestHost.contains(".")) { + if (adServersSet.contains(requestHost)) { + requestHostIsAdServer = true; + } - // Strip out the lowest subdomain of `requestHost`. - requestHost = requestHost.substring(requestHost.indexOf(".") + 1); + // Strip out the lowest subdomain of `requestHost`. + requestHost = requestHost.substring(requestHost.indexOf(".") + 1); + } } if (requestHostIsAdServer) { // It is an ad server. @@ -1518,7 +1519,7 @@ public class MainWebView extends AppCompatActivity implements NavigationView.OnN String fileName = downloadFileNameEditText.getText().toString(); // Once we have `WRITE_EXTERNAL_STORAGE` permissions we can use `setDestinationInExternalPublicDir`. - if (Build.VERSION.SDK_INT >= 23) { // If API >= 23, set the download save in the the `DIRECTORY_DOWNLOADS` using `fileName`. + if (Build.VERSION.SDK_INT >= 23) { // If API >= 23, set the download location to `/sdcard/Android/data/com.stoutner.privacybrowser.standard/files` named `fileName`. downloadRequest.setDestinationInExternalFilesDir(this, "/", fileName); } else { // Only set the title using `fileName`. downloadRequest.setTitle(fileName); diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 83c162b3..bb0444f5 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -18,8 +18,6 @@ You should have received a copy of the GNU General Public License along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>. --> -<!-- `tools:ignore="MissingTranslation"` allows release APKs to be built if translation strings are missing. The missing strings will fall back to English. --> - <resources> <!-- Activities. --> <string name="privacy_browser">Navegador Privado</string> -- 2.47.2