Check pasted content URI type

master
M66B 2 months ago
parent 7e92183f9a
commit c4f39047b4

@ -622,7 +622,7 @@ public class EditTextCompose extends FixedEditText {
ClipData.Item item = cbm.getPrimaryClip().getItemAt(0);
Uri uri = item.getUri();
if (inputContentListener != null && uri != null) {
if (inputContentListener != null && uri != null && "content".equals(uri.getScheme())) {
String type = Helper.guessMimeType(uri.getLastPathSegment());
inputContentListener.onInputContent(uri, type);
return true;
@ -840,6 +840,9 @@ public class EditTextCompose extends FixedEditText {
if (inputContentListener == null)
throw new IllegalArgumentException("InputContent listener not set");
if (!"content".equals(info.getContentUri().getScheme()))
throw new IllegalArgumentException("Invalid uri=" + info.getContentUri());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1 &&
(flags & InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0)
info.requestPermission();

@ -660,7 +660,7 @@ public class FragmentCompose extends FragmentBase {
etBody.setInputContentListener(new EditTextCompose.IInputContentListener() {
@Override
public void onInputContent(Uri uri, String type) {
Log.i("Received input uri=" + uri);
Log.i("Received input uri=" + uri + " type=" + type);
UriType uriType = new UriType(uri, type, null);
onSharedAttachments(new ArrayList<>(Arrays.asList(uriType)));
}

Loading…
Cancel
Save