Merge "Block the content scheme intent in AccountTypePreferenceLoader" into main

This commit is contained in:
Jason Chiu
2024-11-08 10:37:31 +00:00
committed by Android (Google) Code Review
2 changed files with 26 additions and 7 deletions

View File

@@ -30,8 +30,11 @@ import static org.mockito.Mockito.when;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AuthenticatorDescription;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.UserHandle;
import androidx.collection.ArraySet;
@@ -250,4 +253,13 @@ public class AccountTypePreferenceLoaderTest {
mPrefLoader.filterBlockedFragments(parent, Set.of("nomatch", "other"));
verify(pref).setOnPreferenceClickListener(any());
}
@Test
public void isSafeIntent_hasContextScheme_returnFalse() {
Intent intent = new Intent();
intent.setClipData(ClipData.newRawUri(null,
Uri.parse("content://com.android.settings.files/my_cache/NOTICE.html")));
assertThat(mPrefLoader.isSafeIntent(mPackageManager, intent, mAccount.type)).isFalse();
}
}