@@ -56,9 +56,9 @@ class PasswordAutofillService : AutofillService() {
5656 // Regex pattern for detecting username-related ID fields (with word boundaries)
5757 private val USERNAME_ID_PATTERN = Regex (" \\ b(user_?id|login_?id|uid)\\ b" )
5858 // Regex patterns for more precise matching with word boundaries
59- private val USERNAME_PATTERN = Regex (" \\ b(user|login|account|identifier)\\ b" )
59+ private val USERNAME_PATTERN = Regex (" \\ b(username| user|login|account|identifier)\\ b" )
6060 private val EMAIL_PATTERN = Regex (" \\ b(email|e-mail|e_mail)\\ b" )
61- private val PASSWORD_PATTERN = Regex (" \\ bpassword \\ b" )
61+ private val PASSWORD_PATTERN = Regex (" \\ b(password|passwd) \\ b" )
6262 private val PASS_PATTERN = Regex (" \\ bpass\\ b" )
6363 }
6464
@@ -463,10 +463,9 @@ class PasswordAutofillService : AutofillService() {
463463 * Check if a text matches common password field patterns.
464464 */
465465 private fun isPasswordPattern (text : String ): Boolean {
466- // Check for "password", "pass" as standalone words, or "passwd"
466+ // Check for "password", "passwd", or " pass" as standalone words
467467 return PASSWORD_PATTERN .containsMatchIn(text) ||
468- PASS_PATTERN .containsMatchIn(text) ||
469- text.contains(" passwd" )
468+ PASS_PATTERN .containsMatchIn(text)
470469 }
471470
472471 /* *
@@ -529,7 +528,7 @@ class PasswordAutofillService : AutofillService() {
529528 when {
530529 isPasswordPattern(hint) -> return FieldType .PASSWORD
531530 isEmailPattern(hint) -> return FieldType .EMAIL
532- isUsernamePattern(hint) || hint.contains( " username " ) -> return FieldType .USERNAME
531+ isUsernamePattern(hint) -> return FieldType .USERNAME
533532 else -> Unit
534533 }
535534 }
0 commit comments