Check for null URIs

pull/202/head
M66B 4 years ago
parent 1f449c9e58
commit 8f46bdebd1

@ -172,13 +172,17 @@ public class ActivityEML extends ActivityBase {
new SimpleTask<File>() { new SimpleTask<File>() {
@Override @Override
protected File onExecute(Context context, Bundle args) throws Throwable { protected File onExecute(Context context, Bundle args) throws Throwable {
Uri uri = args.getParcelable("uri");
if (uri == null)
throw new FileNotFoundException();
File dir = new File(getCacheDir(), "shared"); File dir = new File(getCacheDir(), "shared");
if (!dir.exists()) if (!dir.exists())
dir.mkdir(); dir.mkdir();
File file = new File(dir, "email.eml"); File file = new File(dir, "email.eml");
Uri uri = args.getParcelable("uri");
Helper.copy(context, uri, file); Helper.copy(context, uri, file);
return file; return file;
} }
@ -489,6 +493,9 @@ public class ActivityEML extends ActivityBase {
protected Void onExecute(Context context, Bundle args) throws Throwable { protected Void onExecute(Context context, Bundle args) throws Throwable {
Uri uri = args.getParcelable("uri"); Uri uri = args.getParcelable("uri");
if (uri == null)
throw new FileNotFoundException();
if (!"content".equals(uri.getScheme())) { if (!"content".equals(uri.getScheme())) {
Log.w("Save attachment uri=" + uri); Log.w("Save attachment uri=" + uri);
throw new IllegalArgumentException(context.getString(R.string.title_no_stream)); throw new IllegalArgumentException(context.getString(R.string.title_no_stream));

@ -19,6 +19,8 @@ package eu.faircode.email;
Copyright 2018-2021 by Marcel Bokhorst (M66B) Copyright 2018-2021 by Marcel Bokhorst (M66B)
*/ */
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_GMAIL;
import android.Manifest; import android.Manifest;
import android.app.Dialog; import android.app.Dialog;
import android.app.NotificationChannel; import android.app.NotificationChannel;
@ -107,8 +109,6 @@ import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.PBEKeySpec;
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_GMAIL;
public class ActivitySetup extends ActivityBase implements FragmentManager.OnBackStackChangedListener { public class ActivitySetup extends ActivityBase implements FragmentManager.OnBackStackChangedListener {
private View view; private View view;
private DrawerLayout drawerLayout; private DrawerLayout drawerLayout;
@ -571,6 +571,10 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
@Override @Override
protected Void onExecute(Context context, Bundle args) throws Throwable { protected Void onExecute(Context context, Bundle args) throws Throwable {
Uri uri = args.getParcelable("uri"); Uri uri = args.getParcelable("uri");
if (uri == null)
throw new FileNotFoundException();
String password = args.getString("password"); String password = args.getString("password");
EntityLog.log(context, "Exporting " + uri); EntityLog.log(context, "Exporting " + uri);
@ -799,6 +803,9 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
" answers=" + import_answers + " answers=" + import_answers +
" settings=" + import_settings); " settings=" + import_settings);
if (uri == null)
throw new FileNotFoundException();
if (!"content".equals(uri.getScheme()) && if (!"content".equals(uri.getScheme()) &&
!Helper.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) { !Helper.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) {
Log.w("Import uri=" + uri); Log.w("Import uri=" + uri);
@ -1403,6 +1410,9 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
Uri uri = args.getParcelable("uri"); Uri uri = args.getParcelable("uri");
Log.i("Import certificate uri=" + uri); Log.i("Import certificate uri=" + uri);
if (uri == null)
throw new FileNotFoundException();
boolean der = false; boolean der = false;
String extension = Helper.getExtension(uri.getLastPathSegment()); String extension = Helper.getExtension(uri.getLastPathSegment());
Log.i("Extension=" + extension); Log.i("Extension=" + extension);

@ -19,6 +19,9 @@ package eu.faircode.email;
Copyright 2018-2021 by Marcel Bokhorst (M66B) Copyright 2018-2021 by Marcel Bokhorst (M66B)
*/ */
import static android.app.ActionBar.DISPLAY_SHOW_CUSTOM;
import static android.app.Activity.RESULT_OK;
import android.app.RecoverableSecurityException; import android.app.RecoverableSecurityException;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
@ -65,9 +68,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static android.app.ActionBar.DISPLAY_SHOW_CUSTOM;
import static android.app.Activity.RESULT_OK;
public class FragmentBase extends Fragment { public class FragmentBase extends Fragment {
private String title = null; private String title = null;
private String subtitle = " "; private String subtitle = " ";
@ -477,6 +477,9 @@ public class FragmentBase extends Fragment {
long id = args.getLong("id"); long id = args.getLong("id");
Uri uri = args.getParcelable("uri"); Uri uri = args.getParcelable("uri");
if (uri == null)
throw new FileNotFoundException();
if (!"content".equals(uri.getScheme())) { if (!"content".equals(uri.getScheme())) {
Log.w("Save attachment uri=" + uri); Log.w("Save attachment uri=" + uri);
throw new IllegalArgumentException(context.getString(R.string.title_no_stream)); throw new IllegalArgumentException(context.getString(R.string.title_no_stream));
@ -552,6 +555,9 @@ public class FragmentBase extends Fragment {
long id = args.getLong("id"); long id = args.getLong("id");
Uri uri = args.getParcelable("uri"); Uri uri = args.getParcelable("uri");
if (uri == null)
throw new FileNotFoundException();
if (!"content".equals(uri.getScheme())) { if (!"content".equals(uri.getScheme())) {
Log.w("Save attachment uri=" + uri); Log.w("Save attachment uri=" + uri);
throw new IllegalArgumentException(context.getString(R.string.title_no_stream)); throw new IllegalArgumentException(context.getString(R.string.title_no_stream));

@ -2503,6 +2503,9 @@ public class FragmentCompose extends FragmentBase {
int requestCode = args.getInt("requestCode"); int requestCode = args.getInt("requestCode");
Uri uri = args.getParcelable("uri"); Uri uri = args.getParcelable("uri");
if (uri == null)
throw new FileNotFoundException();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean suggest_names = prefs.getBoolean("suggest_names", true); boolean suggest_names = prefs.getBoolean("suggest_names", true);

@ -6542,6 +6542,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
long id = args.getLong("id"); long id = args.getLong("id");
Uri uri = args.getParcelable("uri"); Uri uri = args.getParcelable("uri");
if (uri == null)
throw new FileNotFoundException();
if (!"content".equals(uri.getScheme())) { if (!"content".equals(uri.getScheme())) {
Log.w("Save raw uri=" + uri); Log.w("Save raw uri=" + uri);
throw new IllegalArgumentException(context.getString(R.string.title_no_stream)); throw new IllegalArgumentException(context.getString(R.string.title_no_stream));

@ -19,6 +19,8 @@ package eu.faircode.email;
Copyright 2018-2021 by Marcel Bokhorst (M66B) Copyright 2018-2021 by Marcel Bokhorst (M66B)
*/ */
import static android.app.Activity.RESULT_OK;
import android.Manifest; import android.Manifest;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
@ -62,8 +64,6 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import static android.app.Activity.RESULT_OK;
public class FragmentRules extends FragmentBase { public class FragmentRules extends FragmentBase {
private long account; private long account;
private int protocol; private int protocol;
@ -323,6 +323,9 @@ public class FragmentRules extends FragmentBase {
long fid = args.getLong("folder"); long fid = args.getLong("folder");
Uri uri = args.getParcelable("uri"); Uri uri = args.getParcelable("uri");
if (uri == null)
throw new FileNotFoundException();
if (!"content".equals(uri.getScheme())) { if (!"content".equals(uri.getScheme())) {
Log.w("Export uri=" + uri); Log.w("Export uri=" + uri);
throw new IllegalArgumentException(context.getString(R.string.title_no_stream)); throw new IllegalArgumentException(context.getString(R.string.title_no_stream));
@ -387,6 +390,9 @@ public class FragmentRules extends FragmentBase {
long fid = args.getLong("folder"); long fid = args.getLong("folder");
Uri uri = args.getParcelable("uri"); Uri uri = args.getParcelable("uri");
if (uri == null)
throw new FileNotFoundException();
if (!"content".equals(uri.getScheme()) && if (!"content".equals(uri.getScheme()) &&
!Helper.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) { !Helper.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) {
Log.w("Import uri=" + uri); Log.w("Import uri=" + uri);

Loading…
Cancel
Save