From: Soren Stoutner Date: Tue, 21 Mar 2017 04:26:12 +0000 (-0700) Subject: Only apply domain settings to subdomain if the `*.` is used. Fixes https://redmine... X-Git-Tag: v2.0.1~1 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=fc5f976c4e6535abe6c088155d23a67bd4596fd6;p=PrivacyBrowserAndroid.git Only apply domain settings to subdomain if the `*.` is used. Fixes https://redmine.stoutner.com/issues/99. --- 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 08aa9eb2..e06531c6 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -1874,12 +1874,15 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation boolean hostHasDomainSettings = false; String domainNameInDatabase = null; - // Check all the subdomains of `hostname` against the list of domains in `domainCursor`. + // Check the hostname. + if (domainSettingsSet.contains(hostname)) { + hostHasDomainSettings = true; + domainNameInDatabase = hostname; + } + + // Check all the subdomains of `hostname` against wildcard domains in `domainCursor`. while (hostname.contains(".") && !hostHasDomainSettings) { // Stop checking if we run out of `.` or if we already know that `hostHasDomainSettings` is `true`. - if (domainSettingsSet.contains(hostname)) { // Check the host name. - hostHasDomainSettings = true; - domainNameInDatabase = hostname; - } else if (domainSettingsSet.contains("*." + hostname)) { // Check the host name prepended by `*.`. + if (domainSettingsSet.contains("*." + hostname)) { // Check the host name prepended by `*.`. hostHasDomainSettings = true; domainNameInDatabase = "*." + hostname; }