Browse Source

Remove used code in PhoneNumberMatcher as we no more support Israel phone numbers with * (#2267)

pull/2269/head
penmetsaa 7 years ago
committed by Abdulmajid Alnouri
parent
commit
a11c1c8b2e
2 changed files with 0 additions and 48 deletions
  1. +0
    -29
      cpp/src/phonenumbers/phonenumbermatcher.cc
  2. +0
    -19
      java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java

+ 0
- 29
cpp/src/phonenumbers/phonenumbermatcher.cc View File

@ -482,35 +482,6 @@ bool PhoneNumberMatcher::ParseAndVerify(const string& candidate, int offset,
return false;
}
// Check Israel * numbers: these are a special case in that they are
// four-digit numbers that our library supports, but they can only be dialled
// with a leading *. Since we don't actually store or detect the * in our
// phone number library, this means in practice we detect most four digit
// numbers as being valid for Israel. We are considering moving these numbers
// to ShortNumberInfo instead, in which case this problem would go away, but
// in the meantime we want to restrict the false matches so we only allow
// these numbers if they are preceded by a star. We enforce this for all
// leniency levels even though these numbers are technically accepted by
// isPossibleNumber and isValidNumber since we consider it to be a deficiency
// in those methods that they accept these numbers without the *.
// TODO: Remove this or make it significantly less hacky once
// we've decided how to handle these short codes going forward in
// ShortNumberInfo. We could use the formatting rules for instance, but that
// would be slower.
string region_code;
phone_util_.GetRegionCodeForCountryCode(number.country_code(), &region_code);
if (region_code == "IL") {
string national_number;
phone_util_.GetNationalSignificantNumber(number, &national_number);
if (national_number.length() == 4 &&
// Just check the previous char, since * is an ASCII character.
(offset == 0 || (offset > 0 && text_[offset - 1] != '*'))) {
// No match.
return false;
}
}
if (VerifyAccordingToLeniency(leniency_, number, candidate)) {
match->set_start(offset);
match->set_raw_string(candidate);


+ 0
- 19
java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java View File

@ -413,25 +413,6 @@ final class PhoneNumberMatcher implements Iterator<PhoneNumberMatch> {
PhoneNumber number = phoneUtil.parseAndKeepRawInput(candidate, preferredRegion);
// Check Israel * numbers: these are a special case in that they are four-digit numbers that
// our library supports, but they can only be dialled with a leading *. Since we don't
// actually store or detect the * in our phone number library, this means in practice we
// detect most four digit numbers as being valid for Israel. We are considering moving these
// numbers to ShortNumberInfo instead, in which case this problem would go away, but in the
// meantime we want to restrict the false matches so we only allow these numbers if they are
// preceded by a star. We enforce this for all leniency levels even though these numbers are
// technically accepted by isPossibleNumber and isValidNumber since we consider it to be a
// deficiency in those methods that they accept these numbers without the *.
// TODO: Remove this or make it significantly less hacky once we've decided how to
// handle these short codes going forward in ShortNumberInfo. We could use the formatting
// rules for instance, but that would be slower.
if (phoneUtil.getRegionCodeForCountryCode(number.getCountryCode()).equals("IL")
&& phoneUtil.getNationalSignificantNumber(number).length() == 4
&& (offset == 0 || (offset > 0 && text.charAt(offset - 1) != '*'))) {
// No match.
return null;
}
if (leniency.verify(number, candidate, phoneUtil)) {
// We used parseAndKeepRawInput to create this number, but for now we don't return the extra
// values parsed. TODO: stop clearing all values here and switch all users over


Loading…
Cancel
Save