mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix small OTP Auth syntax #556
This commit is contained in:
@@ -238,15 +238,15 @@ object OtpEntryFields {
|
|||||||
}
|
}
|
||||||
val issuer =
|
val issuer =
|
||||||
if (title != null && title.isNotEmpty())
|
if (title != null && title.isNotEmpty())
|
||||||
Uri.encode(title)
|
encodeParameter(title)
|
||||||
else
|
else
|
||||||
Uri.encode(otpElement.issuer)
|
encodeParameter(otpElement.issuer)
|
||||||
val accountName =
|
val accountName =
|
||||||
if (username != null && username.isNotEmpty())
|
if (username != null && username.isNotEmpty())
|
||||||
Uri.encode(username)
|
encodeParameter(username)
|
||||||
else
|
else
|
||||||
Uri.encode(otpElement.name)
|
encodeParameter(otpElement.name)
|
||||||
val uriString = StringBuilder("otpauth://$otpAuthority/$issuer:$accountName" +
|
val uriString = StringBuilder("otpauth://$otpAuthority/$issuer%3A$accountName" +
|
||||||
"?$SECRET_URL_PARAM=${otpElement.getBase32Secret()}" +
|
"?$SECRET_URL_PARAM=${otpElement.getBase32Secret()}" +
|
||||||
"&$counterOrPeriodLabel=$counterOrPeriodValue" +
|
"&$counterOrPeriodLabel=$counterOrPeriodValue" +
|
||||||
"&$DIGITS_URL_PARAM=${otpElement.digits}" +
|
"&$DIGITS_URL_PARAM=${otpElement.digits}" +
|
||||||
@@ -260,6 +260,10 @@ object OtpEntryFields {
|
|||||||
return Uri.parse(uriString.toString())
|
return Uri.parse(uriString.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun encodeParameter(parameter: String): String {
|
||||||
|
return Uri.encode(parameter.replace("[\\r|\\n|\\t|\\u00A0]+".toRegex(), ""))
|
||||||
|
}
|
||||||
|
|
||||||
private fun parseTOTPKeyValues(getField: (id: String) -> String?, otpElement: OtpElement): Boolean {
|
private fun parseTOTPKeyValues(getField: (id: String) -> String?, otpElement: OtpElement): Boolean {
|
||||||
val plainText = getField(OTP_FIELD)
|
val plainText = getField(OTP_FIELD)
|
||||||
if (plainText != null && plainText.isNotEmpty()) {
|
if (plainText != null && plainText.isNotEmpty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user