From 70a69d0ce951d40118cdd9f16857a107bbe88cd0 Mon Sep 17 00:00:00 2001 From: Artem Chepurnoy Date: Tue, 7 May 2024 23:38:05 +0300 Subject: [PATCH] improvement(Autofill): Skip localhost-ed web page hint if it is not a browser --- .../android/autofill/AutofillStructureParser.kt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/autofill/AutofillStructureParser.kt b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/autofill/AutofillStructureParser.kt index e2d0d576..38c08f69 100644 --- a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/autofill/AutofillStructureParser.kt +++ b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/autofill/AutofillStructureParser.kt @@ -523,11 +523,22 @@ class AutofillStructureParser { ) items += item } + + // It it is a web view that renders localhost, + // then ignore the webview hint -- a user is probably + // not supposed to know that anyway. + val isInSelfHostedServer = kotlin.run { + val webDomain = autofillStructure?.webDomain + val webView = autofillStructure?.webView == true + webView && + (webDomain == "127.0.0.1" || + webDomain == "localhost") + } return AutofillStructure2( applicationId = applicationId, - webDomain = autofillStructure?.webDomain, - webScheme = autofillStructure?.webScheme, - webView = autofillStructure?.webView, + webDomain = autofillStructure?.webDomain.takeUnless { isInSelfHostedServer }, + webScheme = autofillStructure?.webScheme.takeUnless { isInSelfHostedServer }, + webView = autofillStructure?.webView.takeUnless { isInSelfHostedServer }, items = items, ) }