mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-22 16:07:30 +00:00
Proper recipient bracket parsing
This commit is contained in:
parent
fa5e993191
commit
575341704e
@ -140,9 +140,16 @@ public class RecipientFactory {
|
|||||||
return recipient;
|
return recipient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean hasBracketedNumber(String recipient) {
|
||||||
|
int openBracketIndex = recipient.indexOf('<');
|
||||||
|
|
||||||
|
return (openBracketIndex != -1) &&
|
||||||
|
(recipient.indexOf('>', openBracketIndex) != -1);
|
||||||
|
}
|
||||||
|
|
||||||
private static String parseBracketedNumber(String recipient) throws RecipientFormattingException {
|
private static String parseBracketedNumber(String recipient) throws RecipientFormattingException {
|
||||||
int begin = recipient.indexOf('<');
|
int begin = recipient.indexOf('<');
|
||||||
int end = recipient.indexOf('>');
|
int end = recipient.indexOf('>', begin);
|
||||||
String value = recipient.substring(begin + 1, end);
|
String value = recipient.substring(begin + 1, end);
|
||||||
|
|
||||||
if (NumberUtil.isValidSmsOrEmail(value))
|
if (NumberUtil.isValidSmsOrEmail(value))
|
||||||
@ -157,7 +164,7 @@ public class RecipientFactory {
|
|||||||
if( recipient.length() == 0 )
|
if( recipient.length() == 0 )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if ((recipient.indexOf('<') != -1) && (recipient.indexOf('>') != -1))
|
if (hasBracketedNumber(recipient))
|
||||||
return getRecipientForNumber(context, parseBracketedNumber(recipient));
|
return getRecipientForNumber(context, parseBracketedNumber(recipient));
|
||||||
|
|
||||||
if (NumberUtil.isValidSmsOrEmail(recipient))
|
if (NumberUtil.isValidSmsOrEmail(recipient))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user