Change Linkify leniency to VALID
The linkify logic used POSSIBLE as its leniency setting, which resulted in false positives such as 4-digit years being interpreted as phone numbers. Changing to VALID as per recommendation of libphonenumber people, which fixes this problem. Bug: 18489494 Change-Id: I77d330285de46de2fdda22daed41392106ec6ddd
This commit is contained in:
@@ -402,7 +402,7 @@ public class Linkify {
|
||||
}
|
||||
|
||||
boolean hasPrefix = false;
|
||||
|
||||
|
||||
for (int i = 0; i < prefixes.length; i++) {
|
||||
if (url.regionMatches(true, 0, prefixes[i], 0,
|
||||
prefixes[i].length())) {
|
||||
@@ -450,7 +450,7 @@ public class Linkify {
|
||||
private static final void gatherTelLinks(ArrayList<LinkSpec> links, Spannable s) {
|
||||
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
|
||||
Iterable<PhoneNumberMatch> matches = phoneUtil.findNumbers(s.toString(),
|
||||
Locale.getDefault().getCountry(), Leniency.POSSIBLE, Long.MAX_VALUE);
|
||||
Locale.getDefault().getCountry(), Leniency.VALID, Long.MAX_VALUE);
|
||||
for (PhoneNumberMatch match : matches) {
|
||||
LinkSpec spec = new LinkSpec();
|
||||
spec.url = "tel:" + PhoneNumberUtils.normalizeNumber(match.rawString());
|
||||
|
||||
Reference in New Issue
Block a user