]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Restrict the File Provider to a subfolder of the cache directory. https://redmine...
authorSoren Stoutner <soren@stoutner.com>
Thu, 10 Nov 2022 21:30:47 +0000 (14:30 -0700)
committerSoren Stoutner <soren@stoutner.com>
Thu, 10 Nov 2022 21:30:47 +0000 (14:30 -0700)
app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.java
app/src/main/res/values-de/strings.xml
app/src/main/res/values-es/strings.xml
app/src/main/res/values-fr/strings.xml
app/src/main/res/values-it/strings.xml
app/src/main/res/values-pt-rBR/strings.xml
app/src/main/res/values-ru/strings.xml
app/src/main/res/values-tr/strings.xml
app/src/main/res/values/strings.xml
app/src/main/res/xml/file_provider_paths.xml

index 7c347a443edae038d77ecb67b63c6c351baefe7e..4c48b42631d560c606e53e655861b028a27d0532 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright © 2018-2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2018-2022 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
  *
  *
  * This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
  *
@@ -105,6 +105,7 @@ public class ImportExportActivity extends AppCompatActivity {
     Button importExportButton;
 
     // Define the class variables.
     Button importExportButton;
 
     // Define the class variables.
+    private File fileProviderDirectory;
     private boolean openKeychainInstalled;
     private File temporaryPgpEncryptedImportFile;
     private File temporaryPreEncryptedExportFile;
     private boolean openKeychainInstalled;
     private File temporaryPgpEncryptedImportFile;
     private File temporaryPreEncryptedExportFile;
@@ -499,6 +500,13 @@ public class ImportExportActivity extends AppCompatActivity {
                     //noinspection ResultOfMethodCallIgnored
                     temporaryPgpEncryptedImportFile.delete();
                 }
                     //noinspection ResultOfMethodCallIgnored
                     temporaryPgpEncryptedImportFile.delete();
                 }
+
+                // Delete the file provider directory if it exists.
+                if (fileProviderDirectory.exists()) {
+                    //noinspection ResultOfMethodCallIgnored
+                    fileProviderDirectory.delete();
+                }
+
                 break;
 
             case OPENPGP_EXPORT_RESULT_CODE:
                 break;
 
             case OPENPGP_EXPORT_RESULT_CODE:
@@ -507,6 +515,13 @@ public class ImportExportActivity extends AppCompatActivity {
                     //noinspection ResultOfMethodCallIgnored
                     temporaryPreEncryptedExportFile.delete();
                 }
                     //noinspection ResultOfMethodCallIgnored
                     temporaryPreEncryptedExportFile.delete();
                 }
+
+                // Delete the file provider directory if it exists.
+                if (fileProviderDirectory.exists()) {
+                    //noinspection ResultOfMethodCallIgnored
+                    fileProviderDirectory.delete();
+                }
+
                 break;
         }
     }
                 break;
         }
     }
@@ -657,8 +672,15 @@ public class ImportExportActivity extends AppCompatActivity {
 
                 case OPENPGP_ENCRYPTION:
                     try {
 
                 case OPENPGP_ENCRYPTION:
                     try {
+                        // Get a handle for the file provider directory.
+                        fileProviderDirectory = new File(getApplicationContext().getCacheDir() + "/" + getString(R.string.file_provider_directory));
+
+                        // Create the file provider directory.  Any errors will be handled by the catch statement below.
+                        //noinspection ResultOfMethodCallIgnored
+                        fileProviderDirectory.mkdir();
+
                         // Set the temporary PGP encrypted import file.
                         // Set the temporary PGP encrypted import file.
-                        temporaryPgpEncryptedImportFile = File.createTempFile("temporary_pgp_encrypted_import_file", null, getApplicationContext().getCacheDir());
+                        temporaryPgpEncryptedImportFile = File.createTempFile("temporary_pgp_encrypted_import_file", null, fileProviderDirectory);
 
                         // Create a temporary PGP encrypted import file output stream.
                         FileOutputStream temporaryPgpEncryptedImportFileOutputStream = new FileOutputStream(temporaryPgpEncryptedImportFile);
 
                         // Create a temporary PGP encrypted import file output stream.
                         FileOutputStream temporaryPgpEncryptedImportFileOutputStream = new FileOutputStream(temporaryPgpEncryptedImportFile);
@@ -858,8 +880,15 @@ public class ImportExportActivity extends AppCompatActivity {
 
                 case OPENPGP_ENCRYPTION:
                     try {
 
                 case OPENPGP_ENCRYPTION:
                     try {
+                        // Get a handle for the file provider directory.
+                        fileProviderDirectory = new File(getApplicationContext().getCacheDir() + "/" + getString(R.string.file_provider_directory));
+
+                        // Create the file provider directory.  Any errors will be handled by the catch statement below.
+                        //noinspection ResultOfMethodCallIgnored
+                        fileProviderDirectory.mkdir();
+
                         // Set the temporary pre-encrypted export file.
                         // Set the temporary pre-encrypted export file.
-                        temporaryPreEncryptedExportFile = new File(getApplicationContext().getCacheDir() + "/" + getString(R.string.settings) + " " + BuildConfig.VERSION_NAME + ".pbs");
+                        temporaryPreEncryptedExportFile = new File(fileProviderDirectory + "/" + getString(R.string.settings) + " " + BuildConfig.VERSION_NAME + ".pbs");
 
                         // Delete the temporary pre-encrypted export file if it already exists.
                         if (temporaryPreEncryptedExportFile.exists()) {
 
                         // Delete the temporary pre-encrypted export file if it already exists.
                         if (temporaryPreEncryptedExportFile.exists()) {
@@ -932,4 +961,4 @@ public class ImportExportActivity extends AppCompatActivity {
         // Restart Privacy Browser after 150 milliseconds to allow enough time for the preferences to be saved.
         restartHandler.postDelayed(restartRunnable, 150);
     }
         // Restart Privacy Browser after 150 milliseconds to allow enough time for the preferences to be saved.
         restartHandler.postDelayed(restartRunnable, 150);
     }
-}
\ No newline at end of file
+}
index f0e0c5ebd161db4813c6d8f4311c70045ce5b210..336b27b0a270a06cc576ccebc4bd21c074cd9bd0 100644 (file)
     <string name="mht_checkbox_explanation">Manchmal müssen MIME-gekapselte HTML-Web-Archive (MHT) manuell festgelegt werden, um korrekt geöffnet zu werden.</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
     <string name="mht_checkbox_explanation">Manchmal müssen MIME-gekapselte HTML-Web-Archive (MHT) manuell festgelegt werden, um korrekt geöffnet zu werden.</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
-        The `%1$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
+        The `%*$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
     <string name="save_url">URL speichern</string>
     <string name="save_archive">Archiv speichern</string>
     <string name="save_text">Text speichern</string>
     <string name="save_url">URL speichern</string>
     <string name="save_archive">Archiv speichern</string>
     <string name="save_text">Text speichern</string>
index a304733fe3a4c48fa8aa9a2b359298c0d17a337d..628fe9b05d159625451fce3b35cc474ae544eccc 100644 (file)
     <string name="mht_checkbox_explanation">A veces se necesita especificar manualmente los archivos web MIME Encapsulated HTML (MHT) para que se abran correctamente.</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
     <string name="mht_checkbox_explanation">A veces se necesita especificar manualmente los archivos web MIME Encapsulated HTML (MHT) para que se abran correctamente.</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
-        The `%1$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
+        The `%*$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
     <string name="save_url">Guardar URL</string>
     <string name="save_archive">Guardar archivo</string>
     <string name="save_text">Guardar texto</string>
     <string name="save_url">Guardar URL</string>
     <string name="save_archive">Guardar archivo</string>
     <string name="save_text">Guardar texto</string>
index 5f9cdc6f3785473ecd193b456ad1ce826fdf29be..6a42d9a56748aa97809b4042fdf3e394cfa83cd1 100644 (file)
     <string name="mht_checkbox_explanation">Parfois, les archives web MHT (MIME Encapsulated HTML) doivent être spécifiées manuellement pour être ouvertes correctement.</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
     <string name="mht_checkbox_explanation">Parfois, les archives web MHT (MIME Encapsulated HTML) doivent être spécifiées manuellement pour être ouvertes correctement.</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
-        The `%1$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
+        The `%*$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
     <string name="save_url">Enregistrer l\'URL</string>
     <string name="save_archive">Enregistrer l\'archive</string>
     <string name="save_text">Sauvegarder le texte</string>
     <string name="save_url">Enregistrer l\'URL</string>
     <string name="save_archive">Enregistrer l\'archive</string>
     <string name="save_text">Sauvegarder le texte</string>
index d601ddbfe5fd335646722437d112a5b14af8d6e3..be1697eb56cd6a0fc5c1002879194d3c7bbffa1f 100644 (file)
     <string name="mht_checkbox_explanation">Talvolta gli archivi web del tipo MIME Encapsulated HTML (MHT) devono essere specificati manualmente per essere aperti correttamente.</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
     <string name="mht_checkbox_explanation">Talvolta gli archivi web del tipo MIME Encapsulated HTML (MHT) devono essere specificati manualmente per essere aperti correttamente.</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
-        The `%1$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
+        The `%*$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
     <string name="save_url">Salva URL</string>
     <string name="save_archive">Salva Archivio</string>
     <string name="save_text">Salva Testo</string>
     <string name="save_url">Salva URL</string>
     <string name="save_archive">Salva Archivio</string>
     <string name="save_text">Salva Testo</string>
index 4dac8dc442696e8f309e8dabdac46e75cc95f301..e5217f016ac14267d724d5c11380206cc47eb723 100644 (file)
     <string name="mht_checkbox_explanation">Às vezes, os arquivos da web MIME Encapsulated HTML (MHT) precisam ser especificados manualmente para serem abertos corretamente.</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
     <string name="mht_checkbox_explanation">Às vezes, os arquivos da web MIME Encapsulated HTML (MHT) precisam ser especificados manualmente para serem abertos corretamente.</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
-        The `%1$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
+        The `%*$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
     <string name="save_url">Salvar URL</string>
     <string name="save_archive">Salvar Arquivo</string>
     <string name="save_text">Salvar Texto</string>
     <string name="save_url">Salvar URL</string>
     <string name="save_archive">Salvar Arquivo</string>
     <string name="save_text">Salvar Texto</string>
index 3afebf9e670bf2987b4ed36b21650d01cd3b98dc..31755ca0c16c4b9493591ff60021cdab2d3270ce 100644 (file)
     <string name="settings">Настройки</string>
     <string name="import_export">Импорт/Экспорт</string>
     <string name="logcat">Logcat</string>
     <string name="settings">Настройки</string>
     <string name="import_export">Импорт/Экспорт</string>
     <string name="logcat">Logcat</string>
+    <string name="webview_devtools">Инструменты разработчика WebView</string>
     <string name="guide">Руководство</string>
     <string name="about">О Privacy Browser</string>
 
     <string name="guide">Руководство</string>
     <string name="about">О Privacy Browser</string>
 
     <string name="mht_checkbox_explanation">Иногда для корректного открытия веб-архивов MIME Encapsulated HTML (MHT) необходимо указать вручную.</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
     <string name="mht_checkbox_explanation">Иногда для корректного открытия веб-архивов MIME Encapsulated HTML (MHT) необходимо указать вручную.</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
-        The `%1$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
+        The `%*$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
     <string name="save_url">Сохранить URL</string>
     <string name="save_archive">Сохранить архив</string>
     <string name="save_text">Сохранить текст</string>
     <string name="save_url">Сохранить URL</string>
     <string name="save_archive">Сохранить архив</string>
     <string name="save_text">Сохранить текст</string>
     <string name="invalid_url">неправильный URL</string>
     <string name="saving_file">Сохранение файла:</string>
     <string name="processing_image">Обработка изображения… :</string>
     <string name="invalid_url">неправильный URL</string>
     <string name="saving_file">Сохранение файла:</string>
     <string name="processing_image">Обработка изображения… :</string>
+    <string name="error_saving_file">Ошибка сохранения %1$s: \u0020 %2$s</string>
+    <string name="unknown_error">Неизвестная ошибка</string>
 
     <!-- View Source. -->
     <string name="request_headers">Заголовки запроса</string>
 
     <!-- View Source. -->
     <string name="request_headers">Заголовки запроса</string>
         <string name="swipe_to_refresh">Потянуть для обновления</string>
         <string name="swipe_to_refresh_summary">Некоторые веб-сайты могут работать некорректно при включении данной опции.</string>
         <string name="download_with_external_app">Загрузка во внешнем приложении</string>
         <string name="swipe_to_refresh">Потянуть для обновления</string>
         <string name="swipe_to_refresh_summary">Некоторые веб-сайты могут работать некорректно при включении данной опции.</string>
         <string name="download_with_external_app">Загрузка во внешнем приложении</string>
+        <string name="download_with_external_app_summary">Внешние приложения не будут учитывать настройки прокси Privacy Browser и не будут иметь доступа к cookie
+            (это означает, что файлы, загруженные с сайтов, для которых требуется авторизация, вряд ли будут работать).</string>
         <string name="scroll_app_bar">Прокручивать панель приложения</string>
         <string name="scroll_app_bar_summary">Прокручивает панель приложения вверху экрана при прокрутке WebView вниз.</string>
         <string name="bottom_app_bar">Нижняя панель приложения</string>
         <string name="scroll_app_bar">Прокручивать панель приложения</string>
         <string name="scroll_app_bar_summary">Прокручивает панель приложения вверху экрана при прокрутке WebView вниз.</string>
         <string name="bottom_app_bar">Нижняя панель приложения</string>
index 90a66064bc3fb26426ada766cd0e691201a4e270..ee19274130c0c668e1922427b1770fb6cd4e7eb5 100644 (file)
     <string name="next">Sonraki</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
     <string name="next">Sonraki</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
-        The `%1$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
+        The `%*$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
     <string name="save_image">Resmi kaydet</string>
     <string name="file_name">Dosya adı</string>
     <string name="unknown_size">Bilinmeyen boyut</string>
     <string name="save_image">Resmi kaydet</string>
     <string name="file_name">Dosya adı</string>
     <string name="unknown_size">Bilinmeyen boyut</string>
index 1e30a7a8c49e50e695877828803dacd7f1d6240b..6f0a5d8f5a7d7055b7dd99c8eb14e9ddb370291a 100644 (file)
@@ -25,6 +25,7 @@
 
     <!-- Providers. -->
     <string name="file_provider" translatable="false">com.stoutner.privacybrowser.fileprovider.standard</string>
 
     <!-- Providers. -->
     <string name="file_provider" translatable="false">com.stoutner.privacybrowser.fileprovider.standard</string>
+    <string name="file_provider_directory" translatable="false">file_provider</string>
 
     <!-- Activities. -->
     <string name="privacy_browser">Privacy Browser</string>
 
     <!-- Activities. -->
     <string name="privacy_browser">Privacy Browser</string>
     <string name="mht_checkbox_explanation">Sometimes MIME Encapsulated HTML (MHT) web archives need to be manually specified to be opened correctly.</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
     <string name="mht_checkbox_explanation">Sometimes MIME Encapsulated HTML (MHT) web archives need to be manually specified to be opened correctly.</string>
 
     <!-- Save Dialog.  Android removes double spaces, but extra spaces can be manually specified with the Unicode `\u0020` formatting.
-        The `%1$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
+        The `%*$s` code inserts variables into the displayed text and should be preserved in translation.  <https://developer.android.com/reference/kotlin/java/util/Formatter> -->
     <string name="save_dialog" translatable="false">Save Dialog</string>  <!-- This string is used to tag the save dialog.  It is never displayed to the user. -->
     <string name="save_url">Save URL</string>
     <string name="save_archive">Save Archive</string>
     <string name="save_dialog" translatable="false">Save Dialog</string>  <!-- This string is used to tag the save dialog.  It is never displayed to the user. -->
     <string name="save_url">Save URL</string>
     <string name="save_archive">Save Archive</string>
     <string name="saving_file">Saving file:</string>
     <string name="saved">%1$s saved.</string>
     <string name="processing_image">Processing image… :</string>
     <string name="saving_file">Saving file:</string>
     <string name="saved">%1$s saved.</string>
     <string name="processing_image">Processing image… :</string>
-    <string name="error_saving_file">Error saving %1$s: \u0020 %2$s</string> -->
+    <string name="error_saving_file">Error saving %1$s: \u0020 %2$s</string>
     <string name="unknown_error">Unknown error</string>
 
     <!-- View Source. -->
     <string name="unknown_error">Unknown error</string>
 
     <!-- View Source. -->
index ffbe1760e991d9f2e6f48339a684832492f34e2f..d37866041152c96665972fe811fe8905743eea09 100644 (file)
@@ -21,5 +21,5 @@
 <paths>
     <cache-path
         name="private-cache-directory"
 <paths>
     <cache-path
         name="private-cache-directory"
-        path="." />
+        path="file_provider" />
 </paths>
 </paths>