Update regular expression pattern for sms verification

Closes #4375
This commit is contained in:
rafael81 2015-11-04 22:18:35 +09:00 committed by Moxie Marlinspike
parent 5757962f95
commit 750e25388f
2 changed files with 4 additions and 3 deletions

View File

@ -38,7 +38,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 TextSecure verification code: ([0-9]{3,4})-([0-9]{3,4}).*");
private static final Pattern CHALLENGE_PATTERN = Pattern.compile(".*\\s*Your TextSecure verification code: ([0-9]{3,4})-([0-9]{3,4}).*");
private boolean isExemption(SmsMessage message, String messageBody) {

View File

@ -38,13 +38,14 @@ import static org.mockito.Mockito.when;
public class SmsListenerTest extends TextSecureTestCase {
private static final String CHALLENGE_SMS_3_3 = "Your TextSecure verification code: 337-337";
private static final String CHALLENGE_SMS_3_3_PREPEND = "XXX\nYour TextSecure verification code: 1337-1337";
private static final String CHALLENGE_SMS_3_4 = "Your TextSecure verification code: 337-1337";
private static final String CHALLENGE_SMS_4_3 = "Your TextSecure verification code: 1337-337";
private static final String CHALLENGE_SMS_4_4 = "Your TextSecure verification code: 1337-1337";
private static final String CHALLENGE_SMS_4_4_PREPEND = "XXXYour TextSecure verification code: 1337-1337";
private static final String CHALLENGE_SMS_4_4_APPEND = "Your TextSecure verification code: 1337-1337XXX";
private static final String[] CHALLENGE_SMS = {
CHALLENGE_SMS_3_3, CHALLENGE_SMS_3_4, CHALLENGE_SMS_4_3,
CHALLENGE_SMS_3_3, CHALLENGE_SMS_3_3_PREPEND, CHALLENGE_SMS_3_4, CHALLENGE_SMS_4_3,
CHALLENGE_SMS_4_4, CHALLENGE_SMS_4_4_PREPEND, CHALLENGE_SMS_4_4_APPEND
};
@ -53,7 +54,7 @@ public class SmsListenerTest extends TextSecureTestCase {
private static final String CHALLENGE_4_3 = "1337337";
private static final String CHALLENGE_4_4 = "13371337";
private static final String[] CHALLENGES = {
CHALLENGE_3_3, CHALLENGE_3_4, CHALLENGE_4_3,
CHALLENGE_3_3, CHALLENGE_3_3, CHALLENGE_3_4, CHALLENGE_4_3,
CHALLENGE_4_4, CHALLENGE_4_4, CHALLENGE_4_4,
};