From bfc6c3dadc5f26c0a9d653325c108a57b1449cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sieradzki?= Date: Tue, 3 Nov 2015 22:21:19 +0100 Subject: [PATCH 1/3] Migrate all trafic to Google services to HTTPS --- .../main/java/acr/browser/lightning/constant/BookmarkPage.java | 2 +- .../acr/browser/lightning/fragment/GeneralSettingsFragment.java | 2 +- .../main/java/acr/browser/lightning/object/SearchAdapter.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java b/app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java index d5f6401..f1f2203 100644 --- a/app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java +++ b/app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java @@ -46,7 +46,7 @@ public final class BookmarkPage { "

\n" + ""; diff --git a/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java b/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java index 1272810..aa3b129 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java +++ b/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java @@ -344,7 +344,7 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme if (!mHomepage.startsWith("about:")) { getHome.setText(mHomepage); } else { - String defaultUrl = "http://www.google.com"; + String defaultUrl = "https://www.google.com"; getHome.setText(defaultUrl); } homePicker.setView(getHome); diff --git a/app/src/main/java/acr/browser/lightning/object/SearchAdapter.java b/app/src/main/java/acr/browser/lightning/object/SearchAdapter.java index 4a2830c..e3f1fff 100644 --- a/app/src/main/java/acr/browser/lightning/object/SearchAdapter.java +++ b/app/src/main/java/acr/browser/lightning/object/SearchAdapter.java @@ -380,7 +380,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable { language = DEFAULT_LANGUAGE; } try { - URL url = new URL("http://google.com/complete/search?q=" + query + URL url = new URL("https://google.com/complete/search?q=" + query + "&output=toolbar&hl=" + language); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoInput(true); From 5059a3d01b6a8bde3f2d50558062ef09320f1e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sieradzki?= Date: Tue, 3 Nov 2015 22:28:07 +0100 Subject: [PATCH 2/3] Fix methods from SHelper Both Google and Facebook force HTTPS-only traffic for years. --- .../main/java/acr/browser/lightning/reading/SHelper.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/reading/SHelper.java b/app/src/main/java/acr/browser/lightning/reading/SHelper.java index 7293f3a..1554ed7 100644 --- a/app/src/main/java/acr/browser/lightning/reading/SHelper.java +++ b/app/src/main/java/acr/browser/lightning/reading/SHelper.java @@ -251,8 +251,8 @@ class SHelper { } public static String getUrlFromUglyGoogleRedirect(String url) { - if (url.startsWith("http://www.google.com/url?")) { - url = url.substring("http://www.google.com/url?".length()); + if (url.startsWith("https://www.google.com/url?")) { + url = url.substring("https://www.google.com/url?".length()); String arr[] = urlDecode(url).split("&"); for (String str : arr) { if (str.startsWith("q=")) @@ -264,8 +264,8 @@ class SHelper { } public static String getUrlFromUglyFacebookRedirect(String url) { - if (url.startsWith("http://www.facebook.com/l.php?u=")) { - url = url.substring("http://www.facebook.com/l.php?u=".length()); + if (url.startsWith("https://www.facebook.com/l.php?u=")) { + url = url.substring("https://www.facebook.com/l.php?u=".length()); return urlDecode(url); } From fd7cc304703b6b3ecaf4cb4173b5d2737c814897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sieradzki?= Date: Tue, 3 Nov 2015 22:28:54 +0100 Subject: [PATCH 3/3] Fix checks to allow both HTTP and HTTPS URLs --- .../main/java/acr/browser/lightning/reading/HtmlFetcher.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/reading/HtmlFetcher.java b/app/src/main/java/acr/browser/lightning/reading/HtmlFetcher.java index 3c58342..c6d7a8b 100644 --- a/app/src/main/java/acr/browser/lightning/reading/HtmlFetcher.java +++ b/app/src/main/java/acr/browser/lightning/reading/HtmlFetcher.java @@ -394,8 +394,8 @@ public class HtmlFetcher { if (responseCode / 100 == 3 && newUrl != null && num_redirects < 5) { newUrl = SPACE.matcher(newUrl).replaceAll("+"); // some services use (none-standard) utf8 in their location header - if (urlAsString.startsWith("http://bit.ly") - || urlAsString.startsWith("http://is.gd")) + if (urlAsString.contains("://bit.ly") + || urlAsString.contains("://is.gd")) newUrl = encodeUriFromHeader(newUrl); // AP: This code is not longer need, instead we always follow