mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-08-04 12:24:00 +01:00
Fix base64 decode issue with short signal.me URLs.
This commit is contained in:
committed by
Michelle Tang
parent
9ca47f5fc5
commit
2162fccd7d
@@ -311,7 +311,11 @@ object UsernameRepository {
|
||||
fun parseLink(url: String): UsernameLinkComponents? {
|
||||
val match: MatchResult = URL_REGEX.find(url) ?: return null
|
||||
val path: String = match.groups[2]?.value ?: return null
|
||||
val allBytes: ByteArray = Base64.decode(path)
|
||||
val allBytes: ByteArray = try {
|
||||
Base64.decode(path)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (allBytes.size != 48) {
|
||||
return null
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package org.thoughtcrime.securesms.profiles.manage
|
||||
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isNull
|
||||
import org.junit.Test
|
||||
|
||||
class UsernameRepositoryTest {
|
||||
@Test
|
||||
fun parseLink_one_character_base64_ref() {
|
||||
val url = "https://signal.me/#eu/A"
|
||||
assertThat(UsernameRepository.parseLink(url)).isNull()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user