mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Change Regex to allow infinite OTP padding #585
This commit is contained in:
@@ -210,13 +210,13 @@ data class OtpElement(var otpModel: OtpModel = OtpModel()) {
|
|||||||
fun isValidBase32(secret: String): Boolean {
|
fun isValidBase32(secret: String): Boolean {
|
||||||
val secretChars = replaceBase32Chars(secret)
|
val secretChars = replaceBase32Chars(secret)
|
||||||
return secret.isNotEmpty()
|
return secret.isNotEmpty()
|
||||||
&& (Pattern.matches("^(?:[A-Z2-7]{8})*(?:[A-Z2-7]{2}={6}|[A-Z2-7]{4}={4}|[A-Z2-7]{5}={3}|[A-Z2-7]{7}=)?$", secretChars))
|
&& (Pattern.matches("^(?:[A-Z2-7]{8})*(?:[A-Z2-7]{2}=*|[A-Z2-7]{4}=*|[A-Z2-7]{5}=*|[A-Z2-7]{7}=*)?$", secretChars))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isValidBase64(secret: String): Boolean {
|
fun isValidBase64(secret: String): Boolean {
|
||||||
// TODO replace base 64 chars
|
// TODO replace base 64 chars
|
||||||
return secret.isNotEmpty()
|
return secret.isNotEmpty()
|
||||||
&& (Pattern.matches("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$", secret))
|
&& (Pattern.matches("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}=*|[A-Za-z0-9+/]{3}=*)?$", secret))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun replaceBase32Chars(parameter: String): String {
|
fun replaceBase32Chars(parameter: String): String {
|
||||||
|
|||||||
Reference in New Issue
Block a user