diff options
Diffstat (limited to 'autofill-parser')
4 files changed, 9 insertions, 17 deletions
diff --git a/autofill-parser/CHANGELOG.md b/autofill-parser/CHANGELOG.md index 1d24d454..71d94cb5 100644 --- a/autofill-parser/CHANGELOG.md +++ b/autofill-parser/CHANGELOG.md @@ -10,6 +10,8 @@ All notable changes to this project will be documented in this file. - Updated `androidx.annotation` to 1.1.0 and `androidx.autofill` to `1.2.0-alpha01`. +- The library now requires Kotlin 1.5.0 configured with `kotlinOptions.languageVersion = "1.5"`. + ### Fixed - Fix build warning from undeclared unsigned type use. 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 109da82c..0bd3d404 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 @@ -39,19 +39,16 @@ internal class FormField( HintConstants.AUTOFILL_HINT_USERNAME, HintConstants.AUTOFILL_HINT_NEW_USERNAME, ) - private val HINTS_NEW_PASSWORD = listOf( HintConstants.AUTOFILL_HINT_NEW_PASSWORD, ) - private val HINTS_PASSWORD = HINTS_NEW_PASSWORD + listOf( HintConstants.AUTOFILL_HINT_PASSWORD, HintConstants.AUTOFILL_HINT_WIFI_PASSWORD, ) - private val HINTS_OTP = listOf( HintConstants.AUTOFILL_HINT_SMS_OTP, @@ -70,7 +67,6 @@ internal class FormField( HintConstants.AUTOFILL_HINT_PHONE, HintConstants.AUTOFILL_HINT_PHONE_NUMBER, ) - private val ANDROID_TEXT_FIELD_CLASS_NAMES = listOf( "android.widget.EditText", @@ -79,9 +75,7 @@ internal class FormField( "android.support.v7.widget.AppCompatEditText", "com.google.android.material.textfield.TextInputEditText", ) - private const val ANDROID_WEB_VIEW_CLASS_NAME = "android.webkit.WebView" - private fun isPasswordInputType(inputType: Int): Boolean { val typeClass = inputType and InputType.TYPE_MASK_CLASS val typeVariation = inputType and InputType.TYPE_MASK_VARIATION @@ -117,7 +111,6 @@ internal class FormField( (HTML_INPUT_FIELD_TYPES_USERNAME + HTML_INPUT_FIELD_TYPES_PASSWORD + HTML_INPUT_FIELD_TYPES_OTP).toSet().toList() @RequiresApi(Build.VERSION_CODES.O) private fun isSupportedHint(hint: String) = hint in HINTS_FILLABLE - private val EXCLUDED_TERMS = listOf( "url_bar", // Chrome/Edge/Firefox address bar @@ -158,14 +151,13 @@ internal class FormField( private val List<String>.anyMatchesFieldInfo get() = any { fieldId.contains(it) || hint.contains(it) || htmlName.contains(it) } - val autofillId: AutofillId = node.autofillId!! // Information for heuristics and exclusion rules based only on the current field private val htmlId = node.htmlInfo?.attributes?.firstOrNull { it.first == "id" }?.second private val resourceId = node.idEntry - private val fieldId = (htmlId ?: resourceId ?: "").toLowerCase(Locale.US) - private val hint = node.hint?.toLowerCase(Locale.US) ?: "" + private val fieldId = (htmlId ?: resourceId ?: "").lowercase(Locale.US) + private val hint = node.hint?.lowercase(Locale.US) ?: "" private val className: String? = node.className private val inputType = node.inputType @@ -186,10 +178,9 @@ internal class FormField( private val htmlTag = node.htmlInfo?.tag private val htmlAttributes: Map<String, String> = node.htmlInfo?.attributes?.filter { it.first != null && it.second != null }?.associate { - Pair(it.first.toLowerCase(Locale.US), it.second.toLowerCase(Locale.US)) + Pair(it.first.lowercase(Locale.US), it.second.lowercase(Locale.US)) } ?: emptyMap() - private val htmlAttributesDebug = htmlAttributes.entries.joinToString { "${it.key}=${it.value}" } private val htmlInputType = htmlAttributes["type"] private val htmlName = htmlAttributes["name"] ?: "" @@ -204,7 +195,6 @@ internal class FormField( // HTML fields with non-fillable types (such as submit buttons) should be excluded here private val isAndroidTextField = !isHtmlField && className in ANDROID_TEXT_FIELD_CLASS_NAMES private val isAndroidPasswordField = isAndroidTextField && hasPasswordInputType - private val isTextField = isAndroidTextField || isHtmlTextField // Autofill hint detection for native fields diff --git a/autofill-parser/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListData.kt b/autofill-parser/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListData.kt index dcef3574..7a17a80f 100644 --- a/autofill-parser/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListData.kt +++ b/autofill-parser/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListData.kt @@ -144,7 +144,7 @@ internal class PublicSuffixListData(private val rules: ByteArray, private val ex companion object { - val WILDCARD_LABEL = byteArrayOf('*'.toByte()) + val WILDCARD_LABEL = byteArrayOf('*'.code.toByte()) val PREVAILING_RULE = listOf("*") val EMPTY_RULE = listOf<String>() const val EXCEPTION_MARKER = '!' diff --git a/autofill-parser/src/main/java/mozilla/components/lib/publicsuffixlist/ext/ByteArray.kt b/autofill-parser/src/main/java/mozilla/components/lib/publicsuffixlist/ext/ByteArray.kt index 59627723..5665db60 100644 --- a/autofill-parser/src/main/java/mozilla/components/lib/publicsuffixlist/ext/ByteArray.kt +++ b/autofill-parser/src/main/java/mozilla/components/lib/publicsuffixlist/ext/ByteArray.kt @@ -42,7 +42,7 @@ internal fun ByteArray.binarySearch(labels: List<ByteArray>, labelIndex: Int): S val byte0 = if (expectDot) { expectDot = false - '.'.toByte() + '.'.code.toByte() } else { labels[currentLabelIndex][currentLabelByteIndex] and BITMASK } @@ -109,7 +109,7 @@ internal fun ByteArray.binarySearch(labels: List<ByteArray>, labelIndex: Int): S /** Search for a '\n' that marks the start of a value. Don't go back past the start of the array. */ private fun ByteArray.findStartOfLineFromIndex(start: Int): Int { var index = start - while (index > -1 && this[index] != '\n'.toByte()) { + while (index > -1 && this[index] != '\n'.code.toByte()) { index-- } index++ @@ -119,7 +119,7 @@ private fun ByteArray.findStartOfLineFromIndex(start: Int): Int { /** Search for a '\n' that marks the end of a value. */ private fun ByteArray.findEndOfLineFromIndex(start: Int): Int { var end = 1 - while (this[start + end] != '\n'.toByte()) { + while (this[start + end] != '\n'.code.toByte()) { end++ } return end |