Validate recipients at send time rather than when constructed.

Fixes #665
This commit is contained in:
Moxie Marlinspike
2014-06-03 14:50:37 -07:00
parent 59899b1caf
commit addea8d340
2 changed files with 9 additions and 14 deletions

View File

@@ -28,6 +28,7 @@ import org.thoughtcrime.securesms.sms.MultipartSmsMessageHandler;
import org.thoughtcrime.securesms.sms.OutgoingPrekeyBundleMessage;
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
import org.thoughtcrime.securesms.sms.SmsTransportDetails;
import org.thoughtcrime.securesms.util.NumberUtil;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.textsecure.crypto.MasterSecret;
import org.whispersystems.textsecure.crypto.SessionCipher;
@@ -54,6 +55,10 @@ public class SmsTransport extends BaseTransport {
throw new UndeliverableMessageException("SMS Transport is not enabled!");
}
if (!NumberUtil.isValidSmsOrEmail(message.getIndividualRecipient().getNumber())) {
throw new UndeliverableMessageException("Not a valid SMS destination! " + message.getIndividualRecipient().getNumber());
}
if (message.isSecure() || message.isKeyExchange() || message.isEndSession()) {
deliverSecureMessage(message);
} else {