diff --git a/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt b/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt index 665e81686..41561b933 100644 --- a/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt +++ b/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt @@ -126,12 +126,14 @@ object AutofillHelper { if (entryInfo.expires) { val year = entryInfo.expiryTime.getYearInt() val month = entryInfo.expiryTime.getMonthInt() + val monthString = month.toString().padStart(2, '0') val day = entryInfo.expiryTime.getDay() + val dayString = day.toString().padStart(2, '0') struct.creditCardExpirationDateId?.let { if (struct.isWebView) { // set date string as defined in https://html.spec.whatwg.org - builder.setValue(it, AutofillValue.forText("$year\u002D$month")) + builder.setValue(it, AutofillValue.forText("$year\u002D$monthString")) } else { builder.setValue(it, AutofillValue.forDate(entryInfo.expiryTime.date.time)) } @@ -157,24 +159,24 @@ object AutofillHelper { } struct.creditCardExpirationMonthId?.let { if (struct.isWebView) { - builder.setValue(it, AutofillValue.forText(month.toString())) + builder.setValue(it, AutofillValue.forText(monthString)) } else { if (struct.creditCardExpirationMonthOptions != null) { // index starts at 0 builder.setValue(it, AutofillValue.forList(month - 1)) } else { - builder.setValue(it, AutofillValue.forText(month.toString())) + builder.setValue(it, AutofillValue.forText(monthString)) } } } struct.creditCardExpirationDayId?.let { if (struct.isWebView) { - builder.setValue(it, AutofillValue.forText(day.toString())) + builder.setValue(it, AutofillValue.forText(dayString)) } else { if (struct.creditCardExpirationDayOptions != null) { builder.setValue(it, AutofillValue.forList(day - 1)) } else { - builder.setValue(it, AutofillValue.forText(day.toString())) + builder.setValue(it, AutofillValue.forText(dayString)) } } } diff --git a/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt b/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt index 2110f2e8f..f10d916e0 100644 --- a/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt +++ b/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt @@ -143,19 +143,19 @@ class StructureParser(private val structure: AssistStructure) { Log.d(TAG, "Autofill password hint") return true } - it.contains("cc-name", true) -> { + it.equals("cc-name", true) -> { Log.d(TAG, "Autofill credit card name hint") result?.creditCardHolderId = autofillId result?.creditCardHolder = node.autofillValue?.textValue?.toString() } it.contains(View.AUTOFILL_HINT_CREDIT_CARD_NUMBER, true) - || it.contains("cc-number", true) -> { + || it.equals("cc-number", true) -> { Log.d(TAG, "Autofill credit card number hint") result?.creditCardNumberId = autofillId result?.creditCardNumber = node.autofillValue?.textValue?.toString() } // expect date string as defined in https://html.spec.whatwg.org, e.g. 2014-12 - it.contains("cc-exp", true) -> { + it.equals("cc-exp", true) -> { Log.d(TAG, "Autofill credit card expiration date hint") result?.creditCardExpirationDateId = autofillId node.autofillValue?.let { value -> @@ -182,7 +182,7 @@ class StructureParser(private val structure: AssistStructure) { } } it.contains(View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR, true) - || it.contains("cc-exp-year", true) -> { + || it.equals("cc-exp-year", true) -> { Log.d(TAG, "Autofill credit card expiration year hint") result?.creditCardExpirationYearId = autofillId if (node.autofillOptions != null) { @@ -204,7 +204,7 @@ class StructureParser(private val structure: AssistStructure) { } } it.contains(View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH, true) - || it.contains("cc-exp-month", true) -> { + || it.equals("cc-exp-month", true) -> { Log.d(TAG, "Autofill credit card expiration month hint") result?.creditCardExpirationMonthId = autofillId if (node.autofillOptions != null) { @@ -227,7 +227,7 @@ class StructureParser(private val structure: AssistStructure) { } } it.contains(View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY, true) - || it.contains("cc-exp-day", true) -> { + || it.equals("cc-exp-day", true) -> { Log.d(TAG, "Autofill credit card expiration day hint") result?.creditCardExpirationDayId = autofillId if (node.autofillOptions != null) {