From 3c99d66ccdbed839dffdfeb07e4f7b564f9e16fc Mon Sep 17 00:00:00 2001 From: haffenloher Date: Wed, 23 Mar 2016 23:47:13 +0100 Subject: [PATCH] Accept verification SMSes with missing colons Apparently some Argentinian mobile providers strip the colons from Signal's verification SMS messages. Fixes #5363 Fixes #3490 Closes #5371 // FREEBIE --- src/org/thoughtcrime/securesms/service/SmsListener.java | 2 +- .../org/thoughtcrime/securesms/service/SmsListenerTest.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/service/SmsListener.java b/src/org/thoughtcrime/securesms/service/SmsListener.java index cdac5f29a4..990629128d 100644 --- a/src/org/thoughtcrime/securesms/service/SmsListener.java +++ b/src/org/thoughtcrime/securesms/service/SmsListener.java @@ -41,7 +41,7 @@ public class SmsListener extends BroadcastReceiver { private static final String SMS_RECEIVED_ACTION = Telephony.Sms.Intents.SMS_RECEIVED_ACTION; private static final String SMS_DELIVERED_ACTION = Telephony.Sms.Intents.SMS_DELIVER_ACTION; - private static final Pattern CHALLENGE_PATTERN = Pattern.compile(".*Your (Signal|TextSecure) verification code: ([0-9]{3,4})-([0-9]{3,4}).*", Pattern.DOTALL); + private static final Pattern CHALLENGE_PATTERN = Pattern.compile(".*Your (Signal|TextSecure) verification code:? ([0-9]{3,4})-([0-9]{3,4}).*", Pattern.DOTALL); private boolean isExemption(SmsMessage message, String messageBody) { diff --git a/test/unitTest/java/org/thoughtcrime/securesms/service/SmsListenerTest.java b/test/unitTest/java/org/thoughtcrime/securesms/service/SmsListenerTest.java index 8ae4033474..6f16602cc6 100644 --- a/test/unitTest/java/org/thoughtcrime/securesms/service/SmsListenerTest.java +++ b/test/unitTest/java/org/thoughtcrime/securesms/service/SmsListenerTest.java @@ -24,6 +24,7 @@ public class SmsListenerTest extends BaseUnitTest { put("Your TextSecure verification code: 1337-1337", "13371337"); put("XXXYour TextSecure verification code: 1337-1337", "13371337"); put("Your TextSecure verification code: 1337-1337XXX", "13371337"); + put("Your TextSecure verification code 1337-1337", "13371337"); put("Your Signal verification code: 337-337", "337337"); put("XXX\nYour Signal verification code: 1337-1337", "13371337"); @@ -32,6 +33,7 @@ public class SmsListenerTest extends BaseUnitTest { put("Your Signal verification code: 1337-1337", "13371337"); put("XXXYour Signal verification code: 1337-1337", "13371337"); put("Your Signal verification code: 1337-1337XXX", "13371337"); + put("Your Signal verification code 1337-1337", "13371337"); }}; private SmsListener listener;