]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/helpers/BlocklistHelper.java
Add kernel information to About > Version. https://redmine.stoutner.com/issues/815
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / helpers / BlocklistHelper.java
index 913cc0b1c775e24ba69689f6b45b402694ba7b52..c194ce6a4d1f6765248ce31a9872cd5c1ca6009b 100644 (file)
@@ -1,20 +1,20 @@
 /*
- * Copyright © 2018-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2018-2019,2021-2022 Soren Stoutner <soren@stoutner.com>.
  *
- * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ * This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
  *
- * Privacy Browser is free software: you can redistribute it and/or modify
+ * Privacy Browser Android is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
  *
- * Privacy Browser is distributed in the hope that it will be useful,
+ * Privacy Browser Android is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>.
+ * along with Privacy Browser Android.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 package com.stoutner.privacybrowser.helpers;
@@ -1634,7 +1634,7 @@ public class BlocklistHelper {
 
         // Process the white lists.
         // Main white list.
-        for (String[] whitelistEntry : blocklist.get(Integer.valueOf(MAIN_WHITELIST))) {
+        for (String[] whitelistEntry : blocklist.get(Integer.parseInt(MAIN_WHITELIST))) {
             switch (whitelistEntry.length) {
                 case 2:  // There is one entry.
                     if (resourceUrl.contains(whitelistEntry[0])) {
@@ -1660,7 +1660,7 @@ public class BlocklistHelper {
         }
 
         // Final white list.
-        for (String[] whitelistEntry : blocklist.get(Integer.valueOf(FINAL_WHITELIST))) {
+        for (String[] whitelistEntry : blocklist.get(Integer.parseInt(FINAL_WHITELIST))) {
             if (whitelistEntry.length == 2) {  // There is one entry.
                 if (resourceUrl.contains(whitelistEntry[0])) {
                     // Return a whitelist match request allowed.
@@ -1677,7 +1677,7 @@ public class BlocklistHelper {
         // Only check the domain lists if the current domain is not null (like `about:blank`).
         if (currentDomain != null) {
             // Domain white list.
-            for (String[] whitelistEntry : blocklist.get(Integer.valueOf(DOMAIN_WHITELIST))) {
+            for (String[] whitelistEntry : blocklist.get(Integer.parseInt(DOMAIN_WHITELIST))) {
                 switch (whitelistEntry.length) {
                     case 3:  // There is one entry.
                         if (currentDomain.endsWith(whitelistEntry[0]) && resourceUrl.contains(whitelistEntry[1])) {
@@ -1714,7 +1714,7 @@ public class BlocklistHelper {
             }
 
             // Domain initial white list.
-            for (String[] whitelistEntry : blocklist.get(Integer.valueOf(DOMAIN_INITIAL_WHITELIST))) {
+            for (String[] whitelistEntry : blocklist.get(Integer.parseInt(DOMAIN_INITIAL_WHITELIST))) {
                 switch (whitelistEntry.length) {
                     case 3:  // There is one entry.
                         if (currentDomain.endsWith(whitelistEntry[0]) && resourceUrl.startsWith(whitelistEntry[1])) {
@@ -1742,7 +1742,7 @@ public class BlocklistHelper {
             }
 
             // Domain final white list.
-            for (String[] whitelistEntry : blocklist.get(Integer.valueOf(DOMAIN_FINAL_WHITELIST))) {
+            for (String[] whitelistEntry : blocklist.get(Integer.parseInt(DOMAIN_FINAL_WHITELIST))) {
                 switch (whitelistEntry.length) {
                     case 3:  // There is one entry;
                         if (currentDomain.endsWith(whitelistEntry[0]) && resourceUrl.endsWith(whitelistEntry[1])) {
@@ -1765,7 +1765,7 @@ public class BlocklistHelper {
         // Only check the third-party white lists if this is a third-party request.
         if (isThirdPartyRequest) {
             // Third-party white list.
-            for (String[] whitelistEntry : blocklist.get(Integer.valueOf(THIRD_PARTY_WHITELIST))) {
+            for (String[] whitelistEntry : blocklist.get(Integer.parseInt(THIRD_PARTY_WHITELIST))) {
                 switch (whitelistEntry.length) {
                     case 2:  // There is one entry
                         if (resourceUrl.contains(whitelistEntry[0])) {
@@ -1809,7 +1809,7 @@ public class BlocklistHelper {
             }
 
             // Third-party domain white list.
-            for (String[] whitelistEntry : blocklist.get(Integer.valueOf(THIRD_PARTY_DOMAIN_WHITELIST))) {
+            for (String[] whitelistEntry : blocklist.get(Integer.parseInt(THIRD_PARTY_DOMAIN_WHITELIST))) {
                 if (whitelistEntry.length == 3) {  // There is one entry.
                     if (currentDomain.endsWith(whitelistEntry[0]) && resourceUrl.contains(whitelistEntry[1])) {
                         // Return a whitelist match request allowed.
@@ -1825,7 +1825,7 @@ public class BlocklistHelper {
             }
 
             // Third-party domain initial white list.
-            for (String[] whitelistEntry : blocklist.get(Integer.valueOf(THIRD_PARTY_DOMAIN_INITIAL_WHITELIST))) {
+            for (String[] whitelistEntry : blocklist.get(Integer.parseInt(THIRD_PARTY_DOMAIN_INITIAL_WHITELIST))) {
                 if (whitelistEntry.length == 3) {  // There is one entry.
                     if (currentDomain.endsWith(whitelistEntry[0]) && resourceUrl.startsWith(whitelistEntry[1])) {
                         // Return a whitelist match request allowed.
@@ -1843,7 +1843,7 @@ public class BlocklistHelper {
 
         // Process the black lists.
         // Main black list.
-        for (String[] blacklistEntry : blocklist.get(Integer.valueOf(MAIN_BLACKLIST))) {
+        for (String[] blacklistEntry : blocklist.get(Integer.parseInt(MAIN_BLACKLIST))) {
             switch (blacklistEntry.length) {
                 case 2:  // There is one entry.
                     if (resourceUrl.contains(blacklistEntry[0])) {
@@ -1886,7 +1886,7 @@ public class BlocklistHelper {
         }
 
         // Initial black list.
-        for (String[] blacklistEntry : blocklist.get(Integer.valueOf(INITIAL_BLACKLIST))) {
+        for (String[] blacklistEntry : blocklist.get(Integer.parseInt(INITIAL_BLACKLIST))) {
             if (blacklistEntry.length == 2) {  // There is one entry.
                 if (resourceUrl.startsWith(blacklistEntry[0])) {
                     // Return a blacklist match request blocked.
@@ -1901,7 +1901,7 @@ public class BlocklistHelper {
         }
 
         // Final black list.
-        for (String[] blacklistEntry : blocklist.get(Integer.valueOf(FINAL_BLACKLIST))) {
+        for (String[] blacklistEntry : blocklist.get(Integer.parseInt(FINAL_BLACKLIST))) {
             switch (blacklistEntry.length) {
                 case 2:  // There is one entry.
                     if (resourceUrl.endsWith(blacklistEntry[0])) {
@@ -1929,7 +1929,7 @@ public class BlocklistHelper {
         // Only check the domain lists if the current domain is not null (like `about:blank`).
         if (currentDomain != null) {
             // Domain black list.
-            for (String[] blacklistEntry : blocklist.get(Integer.valueOf(DOMAIN_BLACKLIST))) {
+            for (String[] blacklistEntry : blocklist.get(Integer.parseInt(DOMAIN_BLACKLIST))) {
                 switch (blacklistEntry.length) {
                     case 3:  // There is one entry.
                         if (currentDomain.endsWith(blacklistEntry[0]) && resourceUrl.contains(blacklistEntry[1])) {
@@ -1957,7 +1957,7 @@ public class BlocklistHelper {
             }
 
             // Domain initial black list.
-            for (String[] blacklistEntry : blocklist.get(Integer.valueOf(DOMAIN_INITIAL_BLACKLIST))) {
+            for (String[] blacklistEntry : blocklist.get(Integer.parseInt(DOMAIN_INITIAL_BLACKLIST))) {
                 // Store the entry in the resource request log.
                 if (currentDomain.endsWith(blacklistEntry[0]) && resourceUrl.startsWith(blacklistEntry[1])) {
                     // Return a blacklist match request blocked.
@@ -1966,7 +1966,7 @@ public class BlocklistHelper {
             }
 
             // Domain final black list.
-            for (String[] blacklistEntry : blocklist.get(Integer.valueOf(DOMAIN_FINAL_BLACKLIST))) {
+            for (String[] blacklistEntry : blocklist.get(Integer.parseInt(DOMAIN_FINAL_BLACKLIST))) {
                 switch (blacklistEntry.length) {
                     case 3:  // There is one entry.
                         if (currentDomain.endsWith(blacklistEntry[0]) && resourceUrl.endsWith(blacklistEntry[1])) {
@@ -1986,7 +1986,7 @@ public class BlocklistHelper {
             }
 
             // Domain regular expression black list.
-            for (String[] blacklistEntry : blocklist.get(Integer.valueOf(DOMAIN_REGULAR_EXPRESSION_BLACKLIST))) {
+            for (String[] blacklistEntry : blocklist.get(Integer.parseInt(DOMAIN_REGULAR_EXPRESSION_BLACKLIST))) {
                 if (currentDomain.endsWith(blacklistEntry[0]) && Pattern.matches(blacklistEntry[1], resourceUrl)) {
                     // Return a blacklist match request blocked.
                     return new String[] {REQUEST_BLOCKED, resourceUrl, BLOCK_LIST_NAME_STRING, DOMAIN_REGULAR_EXPRESSION_BLACKLIST, blacklistEntry[0] + "\n" + blacklistEntry[1], blacklistEntry[2]};
@@ -1997,7 +1997,7 @@ public class BlocklistHelper {
         // Only check the third-party black lists if this is a third-party request.
         if (isThirdPartyRequest) {
             // Third-party black list.
-            for (String[] blacklistEntry : blocklist.get(Integer.valueOf(THIRD_PARTY_BLACKLIST))) {
+            for (String[] blacklistEntry : blocklist.get(Integer.parseInt(THIRD_PARTY_BLACKLIST))) {
                 switch (blacklistEntry.length) {
                     case 2:  // There is one entry.
                         if (resourceUrl.contains(blacklistEntry[0])) {
@@ -2032,7 +2032,7 @@ public class BlocklistHelper {
             }
 
             // Third-party initial black list.
-            for (String[] blacklistEntry : blocklist.get(Integer.valueOf(THIRD_PARTY_INITIAL_BLACKLIST))) {
+            for (String[] blacklistEntry : blocklist.get(Integer.parseInt(THIRD_PARTY_INITIAL_BLACKLIST))) {
                 if (blacklistEntry.length == 2) {  // There is one entry.
                     if (resourceUrl.startsWith(blacklistEntry[0])) {
                         // Return a blacklist match request blocked.
@@ -2047,7 +2047,7 @@ public class BlocklistHelper {
             }
 
             // Third-party domain black list.
-            for (String[] blacklistEntry : blocklist.get(Integer.valueOf(THIRD_PARTY_DOMAIN_BLACKLIST))) {
+            for (String[] blacklistEntry : blocklist.get(Integer.parseInt(THIRD_PARTY_DOMAIN_BLACKLIST))) {
                 if (blacklistEntry.length == 3) {  // There is one entry.
                     if (currentDomain.endsWith(blacklistEntry[0]) && resourceUrl.contains(blacklistEntry[1])) {
                         // Return a blacklist match request blocked.
@@ -2063,7 +2063,7 @@ public class BlocklistHelper {
             }
 
             // Third-party domain initial black list.
-            for (String[] blacklistEntry : blocklist.get(Integer.valueOf(THIRD_PARTY_DOMAIN_INITIAL_BLACKLIST))) {
+            for (String[] blacklistEntry : blocklist.get(Integer.parseInt(THIRD_PARTY_DOMAIN_INITIAL_BLACKLIST))) {
                 switch (blacklistEntry.length) {
                     case 3:  // There is one entry.
                         if (currentDomain.endsWith(blacklistEntry[0]) && resourceUrl.startsWith(blacklistEntry[1])) {
@@ -2091,7 +2091,7 @@ public class BlocklistHelper {
             }
 
             // Third-party regular expression black list.
-            for (String[] blacklistEntry : blocklist.get(Integer.valueOf(THIRD_PARTY_REGULAR_EXPRESSION_BLACKLIST))) {
+            for (String[] blacklistEntry : blocklist.get(Integer.parseInt(THIRD_PARTY_REGULAR_EXPRESSION_BLACKLIST))) {
                 if (Pattern.matches(blacklistEntry[0], resourceUrl)) {
                     // Return a blacklist match request blocked.
                     return new String[] {REQUEST_BLOCKED, resourceUrl, BLOCK_LIST_NAME_STRING, THIRD_PARTY_REGULAR_EXPRESSION_BLACKLIST, blacklistEntry[0], blacklistEntry[1]};
@@ -2099,7 +2099,7 @@ public class BlocklistHelper {
             }
 
             // Third-party domain regular expression black list.
-            for (String[] blacklistEntry : blocklist.get(Integer.valueOf(THIRD_PARTY_DOMAIN_REGULAR_EXPRESSION_BLACKLIST))) {
+            for (String[] blacklistEntry : blocklist.get(Integer.parseInt(THIRD_PARTY_DOMAIN_REGULAR_EXPRESSION_BLACKLIST))) {
                 if (currentDomain.endsWith(blacklistEntry[0]) && Pattern.matches(blacklistEntry[1], resourceUrl)) {
                     // Return a blacklist match request blocked.
                     return new String[] {REQUEST_BLOCKED, resourceUrl, BLOCK_LIST_NAME_STRING, THIRD_PARTY_DOMAIN_REGULAR_EXPRESSION_BLACKLIST, blacklistEntry[0] + "\n" + blacklistEntry[1], blacklistEntry[2]};
@@ -2108,7 +2108,7 @@ public class BlocklistHelper {
         }
 
         // Regular expression black list.
-        for (String[] blacklistEntry : blocklist.get(Integer.valueOf(REGULAR_EXPRESSION_BLACKLIST))) {
+        for (String[] blacklistEntry : blocklist.get(Integer.parseInt(REGULAR_EXPRESSION_BLACKLIST))) {
             if (Pattern.matches(blacklistEntry[0], resourceUrl)) {
                 // Return a blacklist match request blocked.
                 return new String[] {REQUEST_BLOCKED, resourceUrl, BLOCK_LIST_NAME_STRING, REGULAR_EXPRESSION_BLACKLIST, blacklistEntry[0], blacklistEntry[1]};