aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillScenario.kt2
-rw-r--r--autofill-parser/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListData.kt20
-rw-r--r--autofill-parser/src/main/java/mozilla/components/lib/publicsuffixlist/ext/ByteArray.kt1
-rw-r--r--format-common/src/main/kotlin/dev/msfjarvis/aps/data/passfile/PasswordEntry.kt2
-rw-r--r--format-common/src/main/kotlin/dev/msfjarvis/aps/util/totp/Otp.kt6
5 files changed, 12 insertions, 19 deletions
diff --git a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillScenario.kt b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillScenario.kt
index 66ef6d0e..33a2a3fd 100644
--- a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillScenario.kt
+++ b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillScenario.kt
@@ -181,7 +181,7 @@ internal data class ClassifiedAutofillScenario<T : Any>(
override val passwordFieldsToFillOnGenerate
get() = newPassword
override val passwordFieldsToSave
- get() = if (newPassword.isNotEmpty()) newPassword else currentPassword
+ get() = newPassword.ifEmpty { currentPassword }
}
@RequiresApi(Build.VERSION_CODES.O)
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 2bdf5f70..b64b1b2f 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
@@ -39,16 +39,16 @@ internal class PublicSuffixListData(
val rule = findMatchingRule(domainLabels)
- if (domainLabels.size == rule.size && rule[0][0] != PublicSuffixListData.EXCEPTION_MARKER) {
+ if (domainLabels.size == rule.size && rule[0][0] != EXCEPTION_MARKER) {
// The domain is a public suffix.
- return if (rule == PublicSuffixListData.PREVAILING_RULE) {
+ return if (rule == PREVAILING_RULE) {
PublicSuffixOffset.PrevailingRule
} else {
PublicSuffixOffset.PublicSuffix
}
}
- return if (rule[0][0] == PublicSuffixListData.EXCEPTION_MARKER) {
+ return if (rule[0][0] == EXCEPTION_MARKER) {
// Exception rules hold the effective TLD plus one.
PublicSuffixOffset.Offset(domainLabels.size - rule.size)
} else {
@@ -72,15 +72,15 @@ internal class PublicSuffixListData(
val exceptionMatch = findExceptionMatch(domainLabelsBytes, wildcardMatch)
if (exceptionMatch != null) {
- return ("${PublicSuffixListData.EXCEPTION_MARKER}$exceptionMatch").split('.')
+ return ("$EXCEPTION_MARKER$exceptionMatch").split('.')
}
if (exactMatch == null && wildcardMatch == null) {
- return PublicSuffixListData.PREVAILING_RULE
+ return PREVAILING_RULE
}
- val exactRuleLabels = exactMatch?.split('.') ?: PublicSuffixListData.EMPTY_RULE
- val wildcardRuleLabels = wildcardMatch?.split('.') ?: PublicSuffixListData.EMPTY_RULE
+ val exactRuleLabels = exactMatch?.split('.') ?: EMPTY_RULE
+ val wildcardRuleLabels = wildcardMatch?.split('.') ?: EMPTY_RULE
return if (exactRuleLabels.size > wildcardRuleLabels.size) {
exactRuleLabels
@@ -95,7 +95,7 @@ internal class PublicSuffixListData(
// foo.bar.com
// will look like: [foo, bar, com], [bar, com], [com]. The longest matching rule wins.
- for (i in 0 until labels.size) {
+ for (i in labels.indices) {
val rule = binarySearchRules(labels, i)
if (rule != null) {
@@ -118,7 +118,7 @@ internal class PublicSuffixListData(
if (labels.size > 1) {
val labelsWithWildcard = labels.toMutableList()
for (labelIndex in 0 until labelsWithWildcard.size) {
- labelsWithWildcard[labelIndex] = PublicSuffixListData.WILDCARD_LABEL
+ labelsWithWildcard[labelIndex] = WILDCARD_LABEL
val rule = binarySearchRules(labelsWithWildcard, labelIndex)
if (rule != null) {
return rule
@@ -135,7 +135,7 @@ internal class PublicSuffixListData(
return null
}
- for (labelIndex in 0 until labels.size) {
+ for (labelIndex in labels.indices) {
val rule = binarySearchExceptions(labels, labelIndex)
if (rule != null) {
return rule
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 5665db60..9deb9275 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
@@ -19,7 +19,6 @@ private const val BITMASK = 0xff.toByte()
* https://github.com/square/okhttp/blob/1977136/okhttp/src/main/kotlin/okhttp3/internal/publicsuffix/PublicSuffixDatabase.kt
*/
@Suppress("ComplexMethod", "NestedBlockDepth")
-@OptIn(ExperimentalUnsignedTypes::class)
internal fun ByteArray.binarySearch(labels: List<ByteArray>, labelIndex: Int): String? {
var low = 0
var high = size
diff --git a/format-common/src/main/kotlin/dev/msfjarvis/aps/data/passfile/PasswordEntry.kt b/format-common/src/main/kotlin/dev/msfjarvis/aps/data/passfile/PasswordEntry.kt
index c36cb0ed..94149477 100644
--- a/format-common/src/main/kotlin/dev/msfjarvis/aps/data/passfile/PasswordEntry.kt
+++ b/format-common/src/main/kotlin/dev/msfjarvis/aps/data/passfile/PasswordEntry.kt
@@ -13,14 +13,12 @@ import dev.msfjarvis.aps.util.time.UserClock
import dev.msfjarvis.aps.util.totp.Otp
import dev.msfjarvis.aps.util.totp.TotpFinder
import kotlin.collections.set
-import kotlin.time.ExperimentalTime
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
/** Represents a single entry in the password store. */
-@OptIn(ExperimentalTime::class)
public class PasswordEntry
@AssistedInject
constructor(
diff --git a/format-common/src/main/kotlin/dev/msfjarvis/aps/util/totp/Otp.kt b/format-common/src/main/kotlin/dev/msfjarvis/aps/util/totp/Otp.kt
index f1f71e00..0a3921db 100644
--- a/format-common/src/main/kotlin/dev/msfjarvis/aps/util/totp/Otp.kt
+++ b/format-common/src/main/kotlin/dev/msfjarvis/aps/util/totp/Otp.kt
@@ -19,10 +19,6 @@ internal object Otp {
private val BASE_32 = Base32()
private val STEAM_ALPHABET = "23456789BCDFGHJKMNPQRTVWXY".toCharArray()
- init {
- check(STEAM_ALPHABET.size == 26)
- }
-
fun calculateCode(
secret: String,
counter: Long,
@@ -51,7 +47,7 @@ internal object Otp {
var remainingCodeInt = codeInt
buildString {
repeat(5) {
- append(STEAM_ALPHABET[remainingCodeInt % 26])
+ append(STEAM_ALPHABET[remainingCodeInt % STEAM_ALPHABET.size])
remainingCodeInt /= 26
}
}