diff options
Diffstat (limited to 'libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java')
-rw-r--r-- | libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java b/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java index 9aa3152d..bc8a53eb 100644 --- a/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java +++ b/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java @@ -656,7 +656,6 @@ public class PhoneNumberUtil { Matcher trailingCharsMatcher = UNWANTED_END_CHAR_PATTERN.matcher(number); if (trailingCharsMatcher.find()) { number = number.subSequence(0, trailingCharsMatcher.start()); - logger.log(Level.FINER, "Stripped trailing characters: " + number); } // Check for extra numbers at the end. Matcher secondNumber = SECOND_NUMBER_START_PATTERN.matcher(number); @@ -2290,9 +2289,7 @@ public class PhoneNumberUtil { int countryCode = number.getCountryCode(); List<String> regions = countryCallingCodeToRegionCodeMap.get(countryCode); if (regions == null) { - String numberString = getNationalSignificantNumber(number); - logger.log(Level.INFO, - "Missing/invalid country_code (" + countryCode + ") for number " + numberString); + logger.log(Level.INFO, "Missing/invalid country_code (" + countryCode + ")"); return null; } if (regions.size() == 1) { @@ -2481,9 +2478,7 @@ public class PhoneNumberUtil { /** * Helper method to check a number against possible lengths for this region, based on the metadata - * being passed in, and determine whether it matches, or is too short or too long. Currently, if a - * number pattern suggests that numbers of length 7 and 10 are possible, and a number in between - * these possible lengths is entered, such as of length 8, this will return TOO_LONG. + * being passed in, and determine whether it matches, or is too short or too long. */ private ValidationResult testNumberLength(CharSequence number, PhoneMetadata metadata) { return testNumberLength(number, metadata, PhoneNumberType.UNKNOWN); @@ -2491,9 +2486,7 @@ public class PhoneNumberUtil { /** * Helper method to check a number against possible lengths for this number type, and determine - * whether it matches, or is too short or too long. Currently, if a number pattern suggests that - * numbers of length 7 and 10 are possible, and a number in between these possible lengths is - * entered, such as of length 8, this will return TOO_LONG. + * whether it matches, or is too short or too long. */ private ValidationResult testNumberLength( CharSequence number, PhoneMetadata metadata, PhoneNumberType type) { @@ -3225,7 +3218,10 @@ public class PhoneNumberUtil { // We require that the NSN remaining after stripping the national prefix and carrier code be // long enough to be a possible length for the region. Otherwise, we don't do the stripping, // since the original number could be a valid short number. - if (testNumberLength(potentialNationalNumber, regionMetadata) != ValidationResult.TOO_SHORT) { + ValidationResult validationResult = testNumberLength(potentialNationalNumber, regionMetadata); + if (validationResult != ValidationResult.TOO_SHORT + && validationResult != ValidationResult.IS_POSSIBLE_LOCAL_ONLY + && validationResult != ValidationResult.INVALID_LENGTH) { normalizedNationalNumber = potentialNationalNumber; if (keepRawInput && carrierCode.length() > 0) { phoneNumber.setPreferredDomesticCarrierCode(carrierCode.toString()); |