Compare commits

..

1 Commits

Author SHA1 Message Date
Philipp Crocoll
acf55b1f85 trying to reproduce autospill, without success so far (refers to #2478) 2024-01-02 12:44:47 +01:00
5 changed files with 63 additions and 7 deletions

View File

@@ -434,7 +434,7 @@ namespace Kp2aAutofillParser
public static List<string> ConvertToCanonicalLowerCaseHints(string[] supportedHints)
{
List<string> result = new List<string>();
foreach (string hint in supportedHints.Where(h => h != null))
foreach (string hint in supportedHints)
{
var canonicalHint = ToCanonicalHint(hint);
result.Add(canonicalHint.ToLower());
@@ -829,7 +829,7 @@ namespace Kp2aAutofillParser
// * if there is no such autofill hint, we use IsPassword to
HashSet<string> autofillHintsOfAllFields = autofillView.InputFields.Where(f => f.AutofillHints != null)
.SelectMany(f => f.AutofillHints).Where(x => x != null).Select(AutofillHintsHelper.ToCanonicalHint).ToHashSet();
.SelectMany(f => f.AutofillHints).Select(AutofillHintsHelper.ToCanonicalHint).ToHashSet();
bool hasLoginAutofillHints = autofillHintsOfAllFields.Intersect(_autofillHintsForLogin).Any();
if (hasLoginAutofillHints)
@@ -839,9 +839,9 @@ namespace Kp2aAutofillParser
string[] viewHints = viewNode.AutofillHints;
if (viewHints == null)
continue;
if (viewHints.Where(h => h != null).Select(AutofillHintsHelper.ToCanonicalHint).Intersect(_autofillHintsForLogin).Any())
if (viewHints.Select(AutofillHintsHelper.ToCanonicalHint).Intersect(_autofillHintsForLogin).Any())
{
AddFieldToHintMap(viewNode, viewHints.Where(h => h != null).Select(AutofillHintsHelper.ToCanonicalHint).ToHashSet().ToArray());
AddFieldToHintMap(viewNode, viewHints.Select(AutofillHintsHelper.ToCanonicalHint).ToHashSet().ToArray());
}
}

View File

@@ -72,6 +72,13 @@ namespace Kp2aAutofillParserTest
RunTestFromAutofillInput(resourceName, "com.expressvpn.vpn", null);
}
[Fact]
public void HandlesAutospillGracefully()
{
var resourceName = "Kp2aAutofillParserTest.autospill.json";
RunTestFromAutofillInput(resourceName, "com.vivaldi.browser", "m.facebook.com");
}
private void RunTestFromAutofillInput(string resourceName, string expectedPackageName = null, string expectedWebDomain = null)
{
var assembly = Assembly.GetExecutingAssembly();

View File

@@ -9,6 +9,7 @@
</PropertyGroup>
<ItemGroup>
<None Remove="autospill.json" />
<None Remove="chrome-android10-amazon-it.json" />
<None Remove="com-expressvpn-vpn-android13.json" />
<None Remove="com-ifs-banking-fiid3364-android13.json" />
@@ -54,6 +55,9 @@
<EmbeddedResource Include="com-servicenet-mobile-no-focus.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="autospill.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="imdb.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>

View File

@@ -0,0 +1,48 @@
{
"InputFields": [
{
"IdEntry": "native_username",
"ClassName": "android.widget.EditText",
"AutofillHints": null,
"IsFocused": false,
"InputType": 1,
"HtmlInfoTag": null,
"HtmlInfoTypeAttribute": null,
"ExpectedAssignedHints": ["username"]
},
{
"IdEntry": "native_password",
"ClassName": "android.widget.EditText",
"AutofillHints": null,
"IsFocused": false,
"InputType": 129,
"HtmlInfoTag": null,
"HtmlInfoTypeAttribute": null,
"ExpectedAssignedHints": []
},
{
"IdEntry": "webview_email",
"ClassName": "android.widget.EditText",
"AutofillHints": [ "email" ],
"IsFocused": true,
"InputType": 0,
"HtmlInfoTag": null,
"HtmlInfoTypeAttribute": null,
"ExpectedAssignedHints": [ "emailAddress" ]
},
{
"IdEntry": "webview_password",
"ClassName": "android.widget.EditText",
"AutofillHints": [
"password"
],
"IsFocused": false,
"InputType": 0,
"HtmlInfoTag": null,
"HtmlInfoTypeAttribute": null,
"ExpectedAssignedHints": [ "password" ]
}
],
"PackageId": "com.vivaldi.browser",
"WebDomain": "m.facebook.com"
}

View File

@@ -68,8 +68,5 @@
<ItemGroup>
<None Include="Resources\AboutResources.txt" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\values\Strings.xml" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
</Project>