From 8c22a8ab00a5950f161e0c809f8f3e6f0bfb4f71 Mon Sep 17 00:00:00 2001 From: Markus Fisch Date: Sun, 8 Sep 2019 21:15:12 +0200 Subject: [PATCH] Apply auto formatting --- .../binaryeye/actions/otpauth/OtpauthParser.kt | 12 ++++++++---- .../android/binaryeye/actions/vtype/VType.kt | 7 +++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/de/markusfisch/android/binaryeye/actions/otpauth/OtpauthParser.kt b/app/src/main/kotlin/de/markusfisch/android/binaryeye/actions/otpauth/OtpauthParser.kt index b60bb134..70f91bbd 100644 --- a/app/src/main/kotlin/de/markusfisch/android/binaryeye/actions/otpauth/OtpauthParser.kt +++ b/app/src/main/kotlin/de/markusfisch/android/binaryeye/actions/otpauth/OtpauthParser.kt @@ -26,8 +26,9 @@ class OtpauthParser private constructor(private val match: MatchResult) { val counter: Int get() = parameterCounter.toInt() private val isHotp: Boolean = otpType == "hotp" - val isValid: Boolean = (labelIssuer.isNotEmpty() == parameterIssuer.isEmpty() || labelIssuer.isEmpty()) - && secret.isNotEmpty() && isHotp == parameterCounter.isNotEmpty() + val isValid: Boolean = + (labelIssuer.isNotEmpty() == parameterIssuer.isEmpty() || labelIssuer.isEmpty()) + && secret.isNotEmpty() && isHotp == parameterCounter.isNotEmpty() val uri: Uri get() = Uri.Builder().apply { @@ -53,7 +54,8 @@ class OtpauthParser private constructor(private val match: MatchResult) { }.build() companion object { - private const val issuerAndAccount = """(?:(?:([^?:]+)(?::|%3A)(?:%20)*([^?]+))|([^?]+))"""//.toRegex() + private const val issuerAndAccount = + """(?:(?:([^?:]+)(?::|%3A)(?:%20)*([^?]+))|([^?]+))"""//.toRegex() /** allowing `padding` even though it should not be there, will be removed in output*/ private const val secret = """(?:secret=([2-7A-Z]+)=*)"""//.toRegex() /** `\2` references the issuer of [issuerAndAccount] */ @@ -63,7 +65,9 @@ class OtpauthParser private constructor(private val match: MatchResult) { private const val period = """(?:period=([0-9]+))"""//.toRegex() private const val counter = """(?:counter=([0-9]+))"""//.toRegex() private val otpauthRegex = - """^otpauth://([ht]otp)/$issuerAndAccount\?(?:&?(?:$secret|$issuer|$algorithm|$digits|$period|$counter))+$""".toRegex(RegexOption.IGNORE_CASE) + """^otpauth://([ht]otp)/$issuerAndAccount\?(?:&?(?:$secret|$issuer|$algorithm|$digits|$period|$counter))+$""".toRegex( + RegexOption.IGNORE_CASE + ) operator fun invoke(input: String): OtpauthParser? { return otpauthRegex.matchEntire(input)?.let(::OtpauthParser)?.takeIf { it.isValid } diff --git a/app/src/main/kotlin/de/markusfisch/android/binaryeye/actions/vtype/VType.kt b/app/src/main/kotlin/de/markusfisch/android/binaryeye/actions/vtype/VType.kt index 94bcf37c..b46bb587 100644 --- a/app/src/main/kotlin/de/markusfisch/android/binaryeye/actions/vtype/VType.kt +++ b/app/src/main/kotlin/de/markusfisch/android/binaryeye/actions/vtype/VType.kt @@ -1,9 +1,12 @@ package de.markusfisch.android.binaryeye.actions.vtype object VTypeParser { - private const val BACKSLASH_R_LEGACY = "(?:\u000D\u000A|[\u000A\u000B\u000C\u000D\u0085\u2028\u2029])" + private const val BACKSLASH_R_LEGACY = + "(?:\u000D\u000A|[\u000A\u000B\u000C\u000D\u0085\u2028\u2029])" private val vTypeRegex = - """^BEGIN:(VCARD|VEVENT)(?:$BACKSLASH_R_LEGACY.+?:[\s\S]+?)+?${BACKSLASH_R_LEGACY}END:\1$BACKSLASH_R_LEGACY?$""".toRegex(RegexOption.IGNORE_CASE) + """^BEGIN:(VCARD|VEVENT)(?:$BACKSLASH_R_LEGACY.+?:[\s\S]+?)+?${BACKSLASH_R_LEGACY}END:\1$BACKSLASH_R_LEGACY?$""".toRegex( + RegexOption.IGNORE_CASE + ) private val propertyRegex = """^(.+?):([\s\S]*?)$""".toRegex(RegexOption.MULTILINE) fun parseVType(data: String): String? =