]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Update the request headers in View Source. https://redmine.stoutner.com/issues/445
authorSoren Stoutner <soren@stoutner.com>
Wed, 17 Jul 2019 18:39:31 +0000 (11:39 -0700)
committerSoren Stoutner <soren@stoutner.com>
Wed, 17 Jul 2019 18:39:31 +0000 (11:39 -0700)
app/src/main/java/com/stoutner/privacybrowser/asynctasks/GetSource.java
app/src/main/res/values-de/strings.xml
app/src/main/res/values-es/strings.xml
app/src/main/res/values-it/strings.xml
app/src/main/res/values-ru/strings.xml

index 680fb7f88c2492b235e899fd2cd7e80bac1dead4..2a320c39bdb64f65af7209a64069cfda8d0edfde 100644 (file)
@@ -108,7 +108,7 @@ public class GetSource extends AsyncTask<String, Void, SpannableStringBuilder[]>
             // Open a connection to the URL.  No data is actually sent at this point.
             HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection();
 
-            // Instantiate the variables necessary to build the request headers.
+            // Define the variables necessary to build the request headers.
             requestHeadersBuilder = new SpannableStringBuilder();
             int oldRequestHeadersBuilderLength;
             int newRequestHeadersBuilderLength;
@@ -146,37 +146,37 @@ public class GetSource extends AsyncTask<String, Void, SpannableStringBuilder[]>
             requestHeadersBuilder.append(":  keep-alive");
 
 
-            // Set the `User-Agent` header property.
-            httpUrlConnection.setRequestProperty("User-Agent", userAgent);
+            // Set the `Upgrade-Insecure-Requests` header property.
+            httpUrlConnection.setRequestProperty("Upgrade-Insecure-Requests", "1");
 
-            // Add the `User-Agent` header to the string builder and format the text.
+            // Add the `Upgrade-Insecure-Requests` header to the string builder and format the text.
             requestHeadersBuilder.append(System.getProperty("line.separator"));
             if (Build.VERSION.SDK_INT >= 21) {  // Newer versions of Android are so smart.
-                requestHeadersBuilder.append("User-Agent", new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+                requestHeadersBuilder.append("Upgrade-Insecure-Requests", new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
             } else {  // Older versions not so much.
                 oldRequestHeadersBuilderLength = requestHeadersBuilder.length();
-                requestHeadersBuilder.append("User-Agent");
+                requestHeadersBuilder.append("Upgrade-Insecure_Requests");
                 newRequestHeadersBuilderLength = requestHeadersBuilder.length();
                 requestHeadersBuilder.setSpan(new StyleSpan(Typeface.BOLD), oldRequestHeadersBuilderLength + 1, newRequestHeadersBuilderLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
             }
-            requestHeadersBuilder.append(":  ");
-            requestHeadersBuilder.append(userAgent);
+            requestHeadersBuilder.append(":  1");
 
 
-            // Set the `Upgrade-Insecure-Requests` header property.
-            httpUrlConnection.setRequestProperty("Upgrade-Insecure-Requests", "1");
+            // Set the `User-Agent` header property.
+            httpUrlConnection.setRequestProperty("User-Agent", userAgent);
 
-            // Add the `Upgrade-Insecure-Requests` header to the string builder and format the text.
+            // Add the `User-Agent` header to the string builder and format the text.
             requestHeadersBuilder.append(System.getProperty("line.separator"));
             if (Build.VERSION.SDK_INT >= 21) {  // Newer versions of Android are so smart.
-                requestHeadersBuilder.append("Upgrade-Insecure-Requests", new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+                requestHeadersBuilder.append("User-Agent", new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
             } else {  // Older versions not so much.
                 oldRequestHeadersBuilderLength = requestHeadersBuilder.length();
-                requestHeadersBuilder.append("Upgrade-Insecure_Requests");
+                requestHeadersBuilder.append("User-Agent");
                 newRequestHeadersBuilderLength = requestHeadersBuilder.length();
                 requestHeadersBuilder.setSpan(new StyleSpan(Typeface.BOLD), oldRequestHeadersBuilderLength + 1, newRequestHeadersBuilderLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
             }
-            requestHeadersBuilder.append(":  1");
+            requestHeadersBuilder.append(":  ");
+            requestHeadersBuilder.append(userAgent);
 
 
             // Set the `x-requested-with` header property.
@@ -218,7 +218,7 @@ public class GetSource extends AsyncTask<String, Void, SpannableStringBuilder[]>
 
 
             // Set the `Accept` header property.
-            httpUrlConnection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
+            httpUrlConnection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
 
             // Add the `Accept` header to the string builder and format the text.
             requestHeadersBuilder.append(System.getProperty("line.separator"));
@@ -231,7 +231,7 @@ public class GetSource extends AsyncTask<String, Void, SpannableStringBuilder[]>
                 requestHeadersBuilder.setSpan(new StyleSpan(Typeface.BOLD), oldRequestHeadersBuilderLength + 1, newRequestHeadersBuilderLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
             }
             requestHeadersBuilder.append(":  ");
-            requestHeadersBuilder.append("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
+            requestHeadersBuilder.append("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
 
 
             // Instantiate a locale string.
@@ -255,17 +255,37 @@ public class GetSource extends AsyncTask<String, Void, SpannableStringBuilder[]>
                         localesStringBuilder.append(",");
                     }
 
-                    // Get the indicated locale from the list.
-                    localesStringBuilder.append(localeList.get(i));
+                    // Get the locale from the list.
+                    Locale locale = localeList.get(i);
 
-                    // If not the first locale, append `;q=0.i`, which drops by .1 for each removal from the main locale.
+                    // Add the locale to the string.  `locale` by default displays as `en_US`, but WebView uses the `en-US` format.
+                    localesStringBuilder.append(locale.getLanguage());
+                    localesStringBuilder.append("-");
+                    localesStringBuilder.append(locale.getCountry());
+
+                    // If not the first locale, append `;q=0.x`, which drops by .1 for each removal from the main locale until q=0.1.
                     if (q < 10) {
                         localesStringBuilder.append(";q=0.");
                         localesStringBuilder.append(q);
                     }
 
-                    // Decrement `q`.
-                    q--;
+                    // Decrement `q` if it is greater than 1.
+                    if (q > 1) {
+                        q--;
+                    }
+
+                    // Add a second entry for the language only portion of the locale.
+                    localesStringBuilder.append(",");
+                    localesStringBuilder.append(locale.getLanguage());
+
+                    // Append `1;q=0.x`, which drops by .1 for each removal form the main locale until q=0.1.
+                    localesStringBuilder.append(";q=0.");
+                    localesStringBuilder.append(q);
+
+                    // Decrement `q` if it is greater than 1.
+                    if (q > 1) {
+                        q--;
+                    }
                 }
 
                 // Store the populated string builder in the locale string.
index 29b2dafcbd380e2b26106f69d545e35b95b3a63e..ebec1e0ded2eb86b1acaf08d6428b6cdaa9a0c77 100644 (file)
 
     <!-- Context Menus. -->
     <string name="open_in_new_tab">In neuem Tab öffnen</string>
+    <string name="open_image_in_new_tab">Grafik in neuem Tab öffnen</string>
     <string name="copy_url">URL kopieren</string>
     <string name="download_url">Download URL</string>
     <string name="email_address">E-Mail-Adresse</string>
         <string name="block_all_third_party_requests_summary">Alle Zugriffe auf Dritt-Anbieter-Inhalte zu blockieren verbessert die Privatsphäre, kann jedoch Webseiten verunstalten.</string>
     <string name="url_modification">URL-Bereinigung</string>
         <string name="google_analytics">Google Analytics</string>
-        <string name="google_analytics_summary">Entfernt “?utm_” oder “&amp;utm_” sowie alles danach aus URLs.</string>
+        <string name="google_analytics_summary">Entfernt “?utm_” und “&amp;utm_” sowie alles danach aus URLs.</string>
         <string name="facebook_click_ids">Facebook Click-IDs</string>
-        <string name="facebook_click_ids_summary">Entfernt “?fbclid=” or “&amp;fbclid=” sowie alles danach aus URLs.</string>
+        <string name="facebook_click_ids_summary">Entfernt “?fbclid=”, “&amp;fbclid=”, “?fbadid=” und “&amp;fbadid=” sowie alles danach aus URLs.</string>
         <string name="twitter_amp_redirects">Twitter AMP-Umleitungen</string>
         <string name="twitter_amp_redirects_summary">Entfernt “?amp=1” sowie alles danach URLs.</string>
     <string name="tor">Tor</string>
index 769a5c94096f1a54afac47df89d0b0640b54591f..28892e851ced2c12c81e03da586af3fc6f522791 100644 (file)
 
     <!-- Context Menus. -->
     <string name="open_in_new_tab">Abrir en nueva pestaña</string>
+    <string name="open_image_in_new_tab">Abrir imagen en nueva pestaña</string>
     <string name="copy_url">Copiar URL</string>
     <string name="download_url">Descargar URL</string>
     <string name="email_address">Correo electrónico</string>
         <string name="block_all_third_party_requests_summary">Bloquear todas las solicitudes de terceras  partes aumenta la privacidad, pero rompe muchas páginas web.</string>
     <string name="url_modification">Modificación de URL</string>
         <string name="google_analytics">Google Analytics</string>
-        <string name="google_analytics_summary">Eliminar “?utm_” o “&amp;utm_” y cualquier cosa después de esto de las URLs.</string>
+        <string name="google_analytics_summary">Eliminar “?utm_”, “&amp;utm_” y cualquier cosa tras ello de las URLs.</string>
         <string name="facebook_click_ids">IDs de clics en Facebook</string>
-        <string name="facebook_click_ids_summary">Eliminar “?fbclid=” o “&amp;fbclid=” y cualquier cosa después de esto de las URLs.</string>
+        <string name="facebook_click_ids_summary">Eliminar “?fbclid=”, “&amp;fbclid=”, “?fbadid=”, “&amp;fbadid=” y cualquier cosa tras ello de las URLs.</string>
         <string name="twitter_amp_redirects">Redirecciones de Twitter AMP</string>
         <string name="twitter_amp_redirects_summary">Eliminar “?amp=1” y cualquier cosa después de esto de las URLs.</string>
     <string name="tor">Tor</string>
index 854c72da804cb81669eca30003c6f172c7369386..f36315db375d746db1a8746b3056019d32557a0d 100644 (file)
 
     <!-- Context Menus. -->
     <string name="open_in_new_tab">Apri in una nuova Scheda</string>
+    <string name="open_image_in_new_tab">Apri l\'immagine in una nuova scheda</string>
     <string name="copy_url">Copia URL</string>
     <string name="download_url">Scarica URL</string>
     <string name="email_address">Indirizzo Email</string>
         <string name="block_all_third_party_requests_summary">Il blocco di tutte le richieste di Terze Parti aumenta privacy, ma impedisce la visualizzazione di molti siti web.</string>
     <string name="url_modification">Modifica delle URL</string>
         <string name="google_analytics">Google Analytics</string>
-        <string name="google_analytics_summary">Rimuovi “?utm_” o “&amp;utm_” e tutto quello che segue dalle URL.</string>
+        <string name="google_analytics_summary">Rimuovi “?utm_” e “&amp;utm_” e tutto quello che segue dalle URL.</string>
         <string name="facebook_click_ids">Facebook Click ID</string>
-        <string name="facebook_click_ids_summary">Rimuovi “?fbclid=” o “&amp;fbclid=”  e tutto quello che segue dalle URL.</string>
+        <string name="facebook_click_ids_summary">Rimuovi “?fbclid=”, “&amp;fbclid=”, “?fbadid=”, e “&amp;fbadid=” e tutto quello che segue dalle URL.</string>
         <string name="twitter_amp_redirects">Reindirizzamenti Twitter AMP</string>
         <string name="twitter_amp_redirects_summary">Rimuovi “?amp=1”  e tutto quello che segue dalle URL.</string>
     <string name="tor">Tor</string>
index e1aa0a42b29fdfb5e00bac4ca08e01e5ca593012..4f42f347db22a85c71b3255e9c42ebc45c04af49 100644 (file)
 
     <!-- Context Menus. -->
     <string name="open_in_new_tab">Открыть в новой вкладке</string>
+    <string name="open_image_in_new_tab">Открыть изображение в новой вкладке</string>
     <string name="copy_url">Копировать URL</string>
     <string name="download_url">Загрузить URL</string>
     <string name="email_address">Адрес email</string>
         <string name="block_all_third_party_requests_summary">Блокировка всех сторонних запросов повышает конфиденциальность, но ломает многие веб-сайты.</string>
     <string name="url_modification">Модификация URL</string>
         <string name="google_analytics">Google Analytics</string>
-        <string name="google_analytics_summary">Удалять из URL “?utm_” или “&amp;utm_” и все что будет после.</string>
+        <string name="google_analytics_summary">Удалять из URL “?utm_” и “&amp;utm_” и все что будет после.</string>
         <string name="facebook_click_ids">Идентификаторы кликов в Facebook</string>
-        <string name="facebook_click_ids_summary">Удалять из URL “?fbclid=” или “&amp;fbclid=” и все что будет после.</string>
+        <string name="facebook_click_ids_summary">Удалять из URL “?fbclid=”, “&amp;fbclid=”, “?fbadid=”, и “&amp;fbadid=” и все что будет после.</string>
         <string name="twitter_amp_redirects">AMP-перенаправления в Twitter</string>
         <string name="twitter_amp_redirects_summary">Удалять из URL “?amp=1” и все что будет после.</string>
     <string name="tor">Tor</string>