mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-11-29 08:55:48 +00:00
Parse recipient ACIs without dashes as ACIs (#2168)
An ACI was only recognized with dashes. Without them it was passed to the phone number formatter, which removes all letters, so its digits were used as a phone number instead of failing. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8e808a761e
commit
67449bba9a
2 files changed
+40
No files matched your search
@@ -28,6 +28,12 @@ public sealed interface RecipientIdentifier {
|
||||
return new Uuid(UUID.fromString(identifier));
|
||||
}
|
||||
|
||||
// An ACI without dashes, otherwise its digits would be used as a phone number
|
||||
if (identifier.matches("[0-9a-fA-F]{32}")) {
|
||||
return new Uuid(new UUID(Long.parseUnsignedLong(identifier.substring(0, 16), 16),
|
||||
Long.parseUnsignedLong(identifier.substring(16), 16)));
|
||||
}
|
||||
|
||||
if (identifier.startsWith("PNI:")) {
|
||||
final var pni = identifier.substring(4);
|
||||
if (!UuidUtil.INSTANCE.isUuid(pni)) {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.asamk.signal.manager.api;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class RecipientIdentifierTest {
|
||||
|
||||
private static final String LOCAL_NUMBER = "+4915112345678";
|
||||
private static final UUID ACI = UUID.fromString("84edbab3-8d1f-48f1-8bae-debb7bde3c6e");
|
||||
|
||||
@Test
|
||||
void parsesAciWithoutDashesAsUuid() throws Exception {
|
||||
// Previously the letters were removed, and the remaining digits were used as phone number +49843814818736
|
||||
assertEquals(new RecipientIdentifier.Uuid(ACI),
|
||||
RecipientIdentifier.Single.fromString("84edbab38d1f48f18baedebb7bde3c6e", LOCAL_NUMBER));
|
||||
assertEquals(new RecipientIdentifier.Uuid(ACI),
|
||||
RecipientIdentifier.Single.fromString("84EDBAB38D1F48F18BAEDEBB7BDE3C6E", LOCAL_NUMBER));
|
||||
}
|
||||
|
||||
@Test
|
||||
void parsesAciWithDashesAsUuid() throws Exception {
|
||||
assertEquals(new RecipientIdentifier.Uuid(ACI),
|
||||
RecipientIdentifier.Single.fromString(ACI.toString(), LOCAL_NUMBER));
|
||||
}
|
||||
|
||||
@Test
|
||||
void parsesPhoneNumbers() throws Exception {
|
||||
assertEquals(new RecipientIdentifier.Number("+4915187654321"),
|
||||
RecipientIdentifier.Single.fromString("+4915187654321", LOCAL_NUMBER));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user