aboutsummaryrefslogtreecommitdiffstats
path: root/autofill-parser
diff options
context:
space:
mode:
Diffstat (limited to 'autofill-parser')
-rw-r--r--autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FormField.kt9
-rw-r--r--autofill-parser/src/test/kotlin/com/github/androidpasswordstore/autofillparser/FormFieldLogTest.kt19
2 files changed, 27 insertions, 1 deletions
diff --git a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FormField.kt b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FormField.kt
index b8df0664..bcd1081d 100644
--- a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FormField.kt
+++ b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FormField.kt
@@ -141,7 +141,7 @@ internal class FormField(
?.filter { it.first != null && it.second != null }
?.associate { Pair(it.first.lowercase(Locale.US), it.second.lowercase(Locale.US)) }
?: emptyMap()
- private val htmlAttributesDebug = htmlAttributes.entries.joinToString { "${it.key}=${it.value}" }
+ private val htmlAttributesDebug = htmlAttributesForLog(htmlAttributes)
private val htmlInputType = htmlAttributes["type"]
private val htmlName = htmlAttributes["name"] ?: ""
private val htmlMaxLength = htmlAttributes["maxlength"]?.toIntOrNull()
@@ -292,3 +292,10 @@ internal class FormField(
return autofillId.hashCode()
}
}
+
+/** The [attributes] that describe a field: `value` and the like can hold what the user typed. */
+internal fun htmlAttributesForLog(attributes: Map<String, String>): String =
+ attributes
+ .filterKeys { it in setOf("id", "name", "type", "autocomplete", "maxlength") }
+ .entries
+ .joinToString { "${it.key}=${it.value}" }
diff --git a/autofill-parser/src/test/kotlin/com/github/androidpasswordstore/autofillparser/FormFieldLogTest.kt b/autofill-parser/src/test/kotlin/com/github/androidpasswordstore/autofillparser/FormFieldLogTest.kt
new file mode 100644
index 00000000..be6b4b32
--- /dev/null
+++ b/autofill-parser/src/test/kotlin/com/github/androidpasswordstore/autofillparser/FormFieldLogTest.kt
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+package com.github.androidpasswordstore.autofillparser
+
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class FormFieldLogTest {
+
+ @Test
+ fun onlyDescriptiveAttributesAreLogged() {
+ val attributes =
+ mapOf("type" to "email", "value" to "me@example.org", "placeholder" to "me@example.org")
+ assertEquals("type=email", htmlAttributesForLog(attributes))
+ }
+}