mirror of
https://github.com/bitwarden/android.git
synced 2026-06-07 06:49:07 -05:00
BIT-1506: block autofill for block listed URIs (#855)
This commit is contained in:
committed by
Álison Fernandes
parent
c7580c87bd
commit
88da5b2007
@@ -15,6 +15,16 @@ import com.x8bit.bitwarden.data.autofill.util.toAutofillView
|
||||
import com.x8bit.bitwarden.data.autofill.util.website
|
||||
import com.x8bit.bitwarden.data.platform.repository.SettingsRepository
|
||||
|
||||
/**
|
||||
* A list of URIs that should never be autofilled.
|
||||
*/
|
||||
private val BLOCK_LISTED_URIS: List<String> = listOf(
|
||||
"androidapp://android",
|
||||
"androidapp://com.android.settings",
|
||||
"androidapp://com.x8bit.bitwarden",
|
||||
"androidapp://com.oneplus.applocker",
|
||||
)
|
||||
|
||||
/**
|
||||
* The default [AutofillParser] implementation for the app. This is a tool for parsing autofill data
|
||||
* from the OS into domain models.
|
||||
@@ -65,15 +75,19 @@ class AutofillParserImpl(
|
||||
.map { it.autofillViews }
|
||||
.flatten()
|
||||
|
||||
// Find the focused view (or indicate there is no fulfillment to be performed.)
|
||||
val focusedView = autofillViews
|
||||
.firstOrNull { it.data.isFocused }
|
||||
?: return AutofillRequest.Unfillable
|
||||
// Find the focused view.
|
||||
val focusedView = autofillViews.firstOrNull { it.data.isFocused }
|
||||
|
||||
val uri = traversalDataList.buildUriOrNull(
|
||||
assistStructure = assistStructure,
|
||||
)
|
||||
|
||||
val blockListedURIs = settingsRepository.blockedAutofillUris + BLOCK_LISTED_URIS
|
||||
if (focusedView == null || blockListedURIs.contains(uri)) {
|
||||
// The view is unfillable if there are no focused views or the URI is block listed.
|
||||
return AutofillRequest.Unfillable
|
||||
}
|
||||
|
||||
// Choose the first focused partition of data for fulfillment.
|
||||
val partition = when (focusedView) {
|
||||
is AutofillView.Card -> {
|
||||
|
||||
Reference in New Issue
Block a user