Fix single character group links crashing.

This commit is contained in:
Ehren Kret
2026-07-27 12:05:55 -05:00
committed by Michelle Tang
parent e458b3ff66
commit 9ca47f5fc5
2 changed files with 16 additions and 1 deletions
@@ -58,7 +58,13 @@ public final class GroupInviteLinkUrl {
throw new InvalidGroupLinkException("No reference was in the uri");
}
byte[] bytes = Base64.decode(encoding);
byte[] bytes;
try {
bytes = Base64.decode(encoding);
} catch (IllegalArgumentException e) {
throw new InvalidGroupLinkException(e);
}
GroupInviteLink groupInviteLink = GroupInviteLink.ADAPTER.decode(bytes);
//noinspection SwitchStatementWithTooFewBranches
@@ -76,6 +76,15 @@ class GroupInviteLinkUrl_InvalidGroupLinkException_Test {
.isInstanceOf<IOException>()
}
@Test
fun one_character_base64_ref() {
val uri = "https://signal.group/#A"
assertFailure { GroupInviteLinkUrl.fromUri(uri) }
.isInstanceOf<InvalidGroupLinkException>()
.rootCause()
.isInstanceOf<IllegalArgumentException>()
}
@Test
fun bad_protobuf() {
val uri = "https://signal.group/#CAESNAogpQEzURH6BON1bCS264cmTi37Yi6HTOReXZUEHdsBIgSEPCLfiL7k4wCXmwVi31USVY"