Fix finding Otp digits (#511)

If no `digits` was present, this function failed with a
`NullPointerException`.
This commit is contained in:
Bastian Köcher 2019-05-16 09:49:18 +02:00 committed by Harsh Shandilya
parent 064a3fad99
commit 055cacdd91

View file

@ -89,8 +89,8 @@ class PasswordEntry(private val content: String) {
private fun findOtpDigits(decryptedContent: String): String { private fun findOtpDigits(decryptedContent: String): String {
decryptedContent.split("\n".toRegex()).forEach { line -> decryptedContent.split("\n".toRegex()).forEach { line ->
if (line.startsWith("otpauth://totp/") || if ((line.startsWith("otpauth://totp/") ||
line.startsWith("otpauth://hotp/") && line.startsWith("otpauth://hotp/")) &&
Uri.parse(line).getQueryParameter("digits") != null) { Uri.parse(line).getQueryParameter("digits") != null) {
return Uri.parse(line).getQueryParameter("digits")!! return Uri.parse(line).getQueryParameter("digits")!!
} }