From f9b11665878eb92ce96a9406d393ca4c78a1835b Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Fri, 4 Sep 2020 11:51:12 +1000 Subject: [PATCH] Do not parse public key to a number if it's shorter than 12 chars. --- .../securesms/loki/todo/AvatarPlaceholderGenerator.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/loki/todo/AvatarPlaceholderGenerator.kt b/src/org/thoughtcrime/securesms/loki/todo/AvatarPlaceholderGenerator.kt index 4596efd203..9cea1618fd 100644 --- a/src/org/thoughtcrime/securesms/loki/todo/AvatarPlaceholderGenerator.kt +++ b/src/org/thoughtcrime/securesms/loki/todo/AvatarPlaceholderGenerator.kt @@ -19,11 +19,10 @@ object AvatarPlaceholderGenerator { fun generate(context: Context, pixelSize: Int, hashString: String, displayName: String?): BitmapDrawable { //TODO That should be replaced with a proper hash extraction code. val hash: Long - val hexRegex = Regex("^[0-9A-Fa-f]+\$") - if (hashString.length >= 12 && hashString.matches(hexRegex)) { + if (hashString.length >= 12 && hashString.matches(Regex("^[0-9A-Fa-f]+\$"))) { hash = hashString.substring(0 until 12).toLong(16) } else { - hash = hashString.toLong(16) + hash = 0 } // Do not cache color array, it may be different depends on the current theme.