From b0cabbbfc249ad306ec80772a21088738ace579e Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sun, 10 Feb 2019 22:16:16 -0500 Subject: [PATCH] parsed ShouldAutofill with app URL blacklist --- src/Android/Autofill/AutofillHelpers.cs | 6 ++++++ src/Android/Autofill/AutofillService.cs | 3 +-- src/Android/Autofill/Parser.cs | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Android/Autofill/AutofillHelpers.cs b/src/Android/Autofill/AutofillHelpers.cs index 80c34970a..728f5449a 100644 --- a/src/Android/Autofill/AutofillHelpers.cs +++ b/src/Android/Autofill/AutofillHelpers.cs @@ -35,6 +35,12 @@ namespace Bit.Android.Autofill "com.ecosia.android","com.opera.mini.native.beta","org.mozilla.fennec_aurora","com.qwant.liberty" }; + // The URLs are blacklisted from autofilling + public static HashSet BlacklistedUris = new HashSet + { + "androidapp://android", "androidapp://com.x8bit.bitwarden", "androidapp://com.oneplus.applocker" + }; + public static async Task> GetFillItemsAsync(Parser parser, ICipherService service) { var items = new List(); diff --git a/src/Android/Autofill/AutofillService.cs b/src/Android/Autofill/AutofillService.cs index 43441a370..cd0b05430 100644 --- a/src/Android/Autofill/AutofillService.cs +++ b/src/Android/Autofill/AutofillService.cs @@ -34,8 +34,7 @@ namespace Bit.Android.Autofill var parser = new Parser(structure); parser.Parse(); - if(string.IsNullOrWhiteSpace(parser.Uri) || parser.Uri == "androidapp://com.x8bit.bitwarden" || - parser.Uri == "androidapp://android" || !parser.FieldCollection.Fillable) + if(!parser.ShouldAutofill) { return; } diff --git a/src/Android/Autofill/Parser.cs b/src/Android/Autofill/Parser.cs index 2d23092d6..92d80c9b7 100644 --- a/src/Android/Autofill/Parser.cs +++ b/src/Android/Autofill/Parser.cs @@ -76,6 +76,15 @@ namespace Bit.Android.Autofill } } + public bool ShouldAutofill + { + get + { + return !string.IsNullOrWhiteSpace(Uri) && !AutofillHelpers.BlacklistedUris.Contains(Uri) && + FieldCollection != null && FieldCollection.Fillable; + } + } + public void Parse() { for(var i = 0; i < _structure.WindowNodeCount; i++)