diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java index 883a676ee..9ae038069 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java @@ -63,6 +63,9 @@ public class PhoneNumberUtil { static final int MAX_LENGTH_FOR_NSN = 16; // The maximum length of the country calling code. static final int MAX_LENGTH_COUNTRY_CODE = 3; + // We don't allow input strings for parsing to be longer than 250 chars. This prevents malicious + // input from overflowing the regular-expression engine. + private static final int MAX_INPUT_STRING_LENGTH = 250; static final String META_DATA_FILE_PREFIX = "/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto"; private String currentFilePrefix = META_DATA_FILE_PREFIX; @@ -261,7 +264,7 @@ public class PhoneNumberUtil { // plus_sign*(([punctuation]|[star])*[digits]){3,}([punctuation]|[star]|[digits]|[alpha])* // Note VALID_PUNCTUATION starts with a -, so must be the first in the range. private static final String VALID_PHONE_NUMBER = - "[" + PLUS_CHARS + "]*(?:[" + VALID_PUNCTUATION + STAR_SIGN + "]*" + DIGITS + "){3,}[" + + "[" + PLUS_CHARS + "]*+(?:[" + VALID_PUNCTUATION + STAR_SIGN + "]*" + DIGITS + "){3,}[" + VALID_PUNCTUATION + STAR_SIGN + VALID_ALPHA + DIGITS + "]*"; // Default extension prefix to use when formatting. This will be put in front of any extension @@ -1623,9 +1626,13 @@ public class PhoneNumberUtil { } else { // Invalid region entered as country-calling-from (so no metadata was found for it) or the // region chosen has multiple international dialling prefixes. + LOGGER.log(Level.WARNING, + "Trying to format number from invalid region " + + regionCallingFrom + + ". International formatting applied."); prefixNumberWithCountryCallingCode(countryCode, - PhoneNumberFormat.INTERNATIONAL, - formattedNumber); + PhoneNumberFormat.INTERNATIONAL, + formattedNumber); } return formattedNumber.toString(); } @@ -2737,6 +2744,9 @@ public class PhoneNumberUtil { if (numberToParse == null) { throw new NumberParseException(NumberParseException.ErrorType.NOT_A_NUMBER, "The phone number supplied was null."); + } else if (numberToParse.length() > MAX_INPUT_STRING_LENGTH) { + throw new NumberParseException(NumberParseException.ErrorType.TOO_LONG, + "The string supplied was too long to parse."); } // Extract a possible number from the string passed in (this strips leading characters that // could not be the start of a phone number.) diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AC b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AC index fbb7a9140..52de7be79 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AC and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AC differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AM b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AM index c6a514467..54618677d 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AM and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AM differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AT b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AT index 35684449c..751674c43 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AT and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AT differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AZ b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AZ index 75b798b79..34d4f940c 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AZ and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AZ differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BF b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BF index 802997eed..ad53ba8d2 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BF and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BF differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BR b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BR index 31ed9bc75..96d2ae4e6 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BR and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BR differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BY b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BY index 284b3b32f..a78037b19 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BY and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BY differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BZ b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BZ index b1f0a8839..0b04b15a6 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BZ and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BZ differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CR b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CR index 307c8abfc..de374d101 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CR and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CR differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CU b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CU index ec56f92eb..4ff335130 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CU and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CU differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DE b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DE index 673ba16f5..9163e1b0f 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DE and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DE differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DJ b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DJ index 0683a6431..68133054d 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DJ and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DJ differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_EE b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_EE index 89ecb6ec0..5b8327611 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_EE and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_EE differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_EG b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_EG index e82781683..463aaa69c 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_EG and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_EG differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_ET b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_ET index b3bde0046..15e0c7d7c 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_ET and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_ET differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GA b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GA index 438299c66..fb204d089 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GA and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GA differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GH b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GH index aa6e8e773..e268fcca6 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GH and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GH differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HK b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HK index 9e5fa06a3..0b3561a80 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HK and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HK differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HN b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HN index 9339afbcb..c6dfaf927 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HN and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HN differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_ID b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_ID index 5c45880c4..fc2cd499f 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_ID and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_ID differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IN b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IN index f07407afc..6f1ad2831 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IN and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IN differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_JP b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_JP index eaae271cf..e4032ead6 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_JP and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_JP differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KE b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KE index 197ff1edc..a7c91d43f 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KE and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KE differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KG b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KG index 9384fb9a2..f71f076d8 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KG and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KG differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KH b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KH index 3c8e5bd68..9e97693e0 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KH and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KH differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KR b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KR index d8344af86..894849e85 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KR and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KR differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KW b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KW index adb7f31ef..cf386eeab 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KW and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KW differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KY b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KY index cacfd5fab..dc864dda9 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KY and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KY differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LB b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LB index 255bc5f71..6b2dba9cb 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LB and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LB differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LU b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LU index c4951ef9c..f80d82795 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LU and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LU differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MA b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MA index 2850cab12..bf444b7fb 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MA and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MA differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MD b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MD index 565dc363c..3002dfb74 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MD and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MD differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MK b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MK index 010e1269a..5dcd3849a 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MK and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MK differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NA b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NA index 2ee1fa962..3bcfaa801 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NA and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NA differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NE b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NE index 096e04969..e9d67f428 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NE and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NE differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NZ b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NZ index 1c8cb6362..d67fad0ce 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NZ and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NZ differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SA b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SA index b4f4e3b26..fd3ed6b4c 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SA and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SA differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SB b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SB index a5ea1793c..605df51a6 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SB and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SB differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SC b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SC index 7f55e5ae9..a9ca75a94 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SC and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SC differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SE b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SE index a023e7b24..e52ec10fb 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SE and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SE differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SL b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SL index d059d6652..8f7318207 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SL and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SL differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SN b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SN index 3f9e56717..0350bb987 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SN and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SN differ diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_UZ b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_UZ index 18262d29c..aedacceec 100644 Binary files a/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_UZ and b/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_UZ differ diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/AsYouTypeFormatterTest.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/AsYouTypeFormatterTest.java index 24eb8d708..1e2ef4525 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/AsYouTypeFormatterTest.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/AsYouTypeFormatterTest.java @@ -21,18 +21,12 @@ import junit.framework.TestCase; /** * Unit tests for AsYouTypeFormatter.java * - * Note that these tests use the metadata contained in the files with TEST_META_DATA_FILE_PREFIX, - * not the normal metadata files, so should not be used for regression test purposes - these tests - * are illustrative only and test functionality. + * Note that these tests use the test metadata, not the normal metadata file, so should not be used + * for regression test purposes - these tests are illustrative only and test functionality. * * @author Shaopeng Jia */ -public class AsYouTypeFormatterTest extends TestCase { - private PhoneNumberUtil phoneUtil; - - public AsYouTypeFormatterTest() { - phoneUtil = PhoneNumberUtilTest.initializePhoneUtilForTesting(); - } +public class AsYouTypeFormatterTest extends TestMetadataTestCase { public void testInvalidRegion() { AsYouTypeFormatter formatter = phoneUtil.getAsYouTypeFormatter(RegionCode.ZZ); diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java index 9127f7799..30a8faba9 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java @@ -33,13 +33,7 @@ import java.util.NoSuchElementException; * @author Tom Hofmann * @see PhoneNumberUtilTest {@link PhoneNumberUtilTest} for the origin of the test data */ -public class PhoneNumberMatcherTest extends TestCase { - private PhoneNumberUtil phoneUtil; - - @Override - protected void setUp() throws Exception { - phoneUtil = PhoneNumberUtilTest.initializePhoneUtilForTesting(); - } +public class PhoneNumberMatcherTest extends TestMetadataTestCase { /** See {@link PhoneNumberUtilTest#testParseNationalNumber()}. */ public void testFindNationalNumber() throws Exception { @@ -710,6 +704,19 @@ public class PhoneNumberMatcherTest extends TestCase { assertEquals(expected, actual); } + public void testNonPlusPrefixedNumbersNotFoundForInvalidRegion() throws Exception { + // Does not start with a "+", we won't match it. + Iterable iterable = phoneUtil.findNumbers("1 456 764 156", RegionCode.ZZ); + Iterator iterator = iterable.iterator(); + + assertFalse(iterator.hasNext()); + try { + iterator.next(); + fail("Violation of the Iterator contract."); + } catch (NoSuchElementException e) { /* Success */ } + assertFalse(iterator.hasNext()); + } + public void testEmptyIteration() throws Exception { Iterable iterable = phoneUtil.findNumbers("", RegionCode.ZZ); Iterator iterator = iterable.iterator(); diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java index d78e80f1e..fd151689a 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java @@ -31,19 +31,13 @@ import java.util.List; /** * Unit tests for PhoneNumberUtil.java * - * Note that these tests use the metadata contained in the files with TEST_META_DATA_FILE_PREFIX, - * not the normal metadata files, so should not be used for regression test purposes - these tests - * are illustrative only and test functionality. + * Note that these tests use the test metadata, not the normal metadata file, so should not be used + * for regression test purposes - these tests are illustrative only and test functionality. * * @author Shaopeng Jia * @author Lara Rennie */ -public class PhoneNumberUtilTest extends TestCase { - private PhoneNumberUtil phoneUtil; - // This is used by BuildMetadataProtoFromXml. - static final String TEST_META_DATA_FILE_PREFIX = - "/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting"; - +public class PhoneNumberUtilTest extends TestMetadataTestCase { // Set up some test numbers to re-use. private static final PhoneNumber ALPHA_NUMERIC_NUMBER = new PhoneNumber().setCountryCode(1).setNationalNumber(80074935247L); @@ -110,17 +104,6 @@ public class PhoneNumberUtilTest extends TestCase { private static final PhoneNumber INTERNATIONAL_TOLL_FREE_TOO_LONG = new PhoneNumber().setCountryCode(800).setNationalNumber(1234567890L); - public PhoneNumberUtilTest() { - phoneUtil = initializePhoneUtilForTesting(); - } - - static PhoneNumberUtil initializePhoneUtilForTesting() { - PhoneNumberUtil.resetInstance(); - return PhoneNumberUtil.getInstance( - TEST_META_DATA_FILE_PREFIX, - CountryCodeToRegionCodeMapForTesting.getCountryCodeToRegionCodeMap()); - } - public void testGetSupportedRegions() { assertTrue(phoneUtil.getSupportedRegions().size() > 0); } @@ -1036,11 +1019,9 @@ public class PhoneNumberUtilTest extends TestCase { // Invalid country calling codes. invalidNumber.setCountryCode(3923).setNationalNumber(2366L); assertFalse(phoneUtil.isValidNumberForRegion(invalidNumber, RegionCode.ZZ)); - invalidNumber.setCountryCode(3923).setNationalNumber(2366L); - assertFalse(phoneUtil.isValidNumberForRegion(invalidNumber, RegionCode.UN001)); - invalidNumber.setCountryCode(0).setNationalNumber(2366L); assertFalse(phoneUtil.isValidNumberForRegion(invalidNumber, RegionCode.UN001)); invalidNumber.setCountryCode(0); + assertFalse(phoneUtil.isValidNumberForRegion(invalidNumber, RegionCode.UN001)); assertFalse(phoneUtil.isValidNumberForRegion(invalidNumber, RegionCode.ZZ)); } @@ -1594,6 +1575,38 @@ public class PhoneNumberUtilTest extends TestCase { assertEquals(premiumNumber, phoneUtil.parse("0900 a332 600A5", RegionCode.NZ)); } + public void testParseMaliciousInput() throws Exception { + // Lots of leading + signs before the possible number. + StringBuilder maliciousNumber = new StringBuilder(6000); + for (int i = 0; i < 6000; i++) { + maliciousNumber.append('+'); + } + maliciousNumber.append("12222-33-244 extensioB 343+"); + try { + phoneUtil.parse(maliciousNumber.toString(), RegionCode.US); + fail("This should not parse without throwing an exception " + maliciousNumber); + } catch (NumberParseException e) { + // Expected this exception. + assertEquals("Wrong error type stored in exception.", + NumberParseException.ErrorType.TOO_LONG, + e.getErrorType()); + } + StringBuilder maliciousNumberWithAlmostExt = new StringBuilder(6000); + for (int i = 0; i < 350; i++) { + maliciousNumberWithAlmostExt.append("200"); + } + maliciousNumberWithAlmostExt.append(" extensiOB 345"); + try { + phoneUtil.parse(maliciousNumberWithAlmostExt.toString(), RegionCode.US); + fail("This should not parse without throwing an exception " + maliciousNumberWithAlmostExt); + } catch (NumberParseException e) { + // Expected this exception. + assertEquals("Wrong error type stored in exception.", + NumberParseException.ErrorType.TOO_LONG, + e.getErrorType()); + } + } + public void testParseWithInternationalPrefixes() throws Exception { assertEquals(US_NUMBER, phoneUtil.parse("+1 (650) 253-0000", RegionCode.NZ)); assertEquals(INTERNATIONAL_TOLL_FREE, phoneUtil.parse("011 800 1234 5678", RegionCode.US)); diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/ShortNumberUtilTest.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/ShortNumberUtilTest.java index 20644d211..c6d2c7481 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/ShortNumberUtilTest.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/ShortNumberUtilTest.java @@ -25,16 +25,10 @@ import java.io.InputStream; * * @author Shaopeng Jia */ -public class ShortNumberUtilTest extends TestCase { +public class ShortNumberUtilTest extends TestMetadataTestCase { private ShortNumberUtil shortUtil; - static final String TEST_META_DATA_FILE_PREFIX = - "/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting"; public ShortNumberUtilTest() { - PhoneNumberUtil.resetInstance(); - PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance( - TEST_META_DATA_FILE_PREFIX, - CountryCodeToRegionCodeMapForTesting.getCountryCodeToRegionCodeMap()); shortUtil = new ShortNumberUtil(phoneUtil); } diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/TestMetadataTestCase.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/TestMetadataTestCase.java new file mode 100644 index 000000000..457712570 --- /dev/null +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/TestMetadataTestCase.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2012 The Libphonenumber Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.i18n.phonenumbers; + +import junit.framework.TestCase; + +import java.io.IOException; +import java.io.InputStream; + +/** + * Root class for PhoneNumberUtil tests that depend on the test metadata file. + *

+ * Note since tests that extend this class do not use the normal metadata file, they should not be + * used for regression test purposes. + * + * @author Shaopeng Jia + * @author Lara Rennie + */ +public class TestMetadataTestCase extends TestCase { + private static final String TEST_META_DATA_FILE_PREFIX = + "/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting"; + + protected final PhoneNumberUtil phoneUtil; + + public TestMetadataTestCase() { + phoneUtil = initializePhoneUtilForTesting(); + } + + static PhoneNumberUtil initializePhoneUtilForTesting() { + PhoneNumberUtil.resetInstance(); + PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance( + TEST_META_DATA_FILE_PREFIX, + CountryCodeToRegionCodeMapForTesting.getCountryCodeToRegionCodeMap()); + return phoneUtil; + } +} diff --git a/java/release_notes.txt b/java/release_notes.txt index 5970332a7..ecfdd28e2 100644 --- a/java/release_notes.txt +++ b/java/release_notes.txt @@ -1,3 +1,12 @@ +March 16th, 2012: libphonenumber-4.7 +* Bug fixes + - Now return "too long" for input that is longer than 250 chars when parsing +* Metadata changes + - AC,AM,AT,AZ,BF,BR,BY,BZ,CR,CU,DE,DJ,EE,EG,ET,GA,GH,HK,HN,ID,IN,JP,KE,KG,KH,KR,KW,KY,LB,LU,MA,MD, + MK,NA,NE,NZ,SA,SB,SC,SE,SL,SN,UZ + * Refactoring of test classes so that tests requiring the test metadata to be loaded have a common + base class which handles this. + February 9th, 2012: libphonenumber-4.6 * Bug fixes - Fix for formatByPattern to enable RFC formatting to work diff --git a/resources/PhoneNumberMetaData.xml b/resources/PhoneNumberMetaData.xml index bdbf55cb1..6fe4704cb 100644 --- a/resources/PhoneNumberMetaData.xml +++ b/resources/PhoneNumberMetaData.xml @@ -30,7 +30,7 @@ applied. Country code, international and national prefix information main source: - http://www.itu.int/publ/T-SP-E.164C-2010/en + http://www.itu.int/pub/T-SP-E.164C-2011 Emergency numbers Wikipedia source: http://en.wikipedia.org/wiki/Emergency_telephone_number @@ -94,15 +94,18 @@ - [2-46]\d{3} + [2-467]\d{3} \d{4} + (?: 3[0-5]| 4[4-6]| - [26]\d + [26]\d| + 70 )\d{2} \d{4} @@ -573,7 +576,10 @@ nationalPrefix="0" nationalPrefixFormattingRule="($NP$FG)"> - 1 + + 1| + 47 + $1 $2 @@ -596,10 +602,12 @@ - [1-35-9]\d{7} + [1-9]\d{7} \d{5,8} + (?: 10\d| @@ -611,14 +619,16 @@ 6[1-9]| 8[1-7] )| - 3[12]2 + 3[12]2| + 47\d )\d{5} 10123456 + seems to be used by Orange Armenia. Part of the range 97 is used by Nagorno-Karabakh + Republic. --> (?: 55| @@ -1322,7 +1332,7 @@ (?: 2(?: 1[467]| - 2[134-8]| + 2[13-8]| 5[2357]| 6[1-46-8]| 7[1-8]| @@ -1817,26 +1827,7 @@ $1 $2 $3 $4 - - 22 - $1 $2 $3 $4 - - - 36[0-46-9] - $1 $2 $3 $4 - - - - 1[013-79]| - 2(?: - [45][13-9]| - [7-9] - ) - - $1 $2 $3 $4 - - + [4-8] $1 $2 $3 $4 @@ -1847,73 +1838,32 @@ - [1-9]\d{7,8} - \d{5,9} + [1-9]\d{8} + \d{7,9} - (?: - 1(?: - (?: - [28]\d| - 9 - )\d| - 02| - 1[0-589]| - 3[358]| - 4[013-79]| - 5[0-479]| - 6[02346-9]| - 7[0-24-8] - )| + 1[28]\d| 2(?: - 02\d| - 1(?: - 2[0-8]| - 42| - 6 - )| - 2(?: - 2[0-79]| - 3[0-35]| - 42| - [1-35-9]| - )| - 3(?: - 3[0-58]| - [0-24] - )| - 4(?: - 2[0124579]| - [1468] - )| - 5(?: - 2[0124579]| - 5 - )| - 6(?: - 2\d| - 3[0128]| - [56] - )| - 79 + 02| + 1[24]| + 2[2-4]| + 33| + [45]2| + 6[23] )| - 365?\d| - 44\d{2} - )\d{5} + 365 + )\d{6} 123123456 (?: - [46]0| + 4[04]| 5[015]| + 60| 7[07] )\d{7} @@ -2454,11 +2404,14 @@ Including 716 as well since many numbers seem to have this prefix. --> (?: - 60[0-3]| + 6(?: + 0[0-3]| + 8\d + )| 7(?: [02-68]\d| 1[0-4689]| - 7[0-6]| + 7[0-69]| 9[0-689] ) )\d{5} @@ -3060,17 +3013,24 @@ - + + + 119 + $1 $2-$3 + @@ -3088,8 +3048,11 @@ - [1-9]\d{7,9} - \d{8,10} + + [1-46-9]\d{7,10}| + 5\d{8,9} + + \d{8,11} [34]00\d{5} @@ -3118,8 +3081,9 @@ 1(?: 1(?: - [6-9]\d| - 5[347] + 5[347]| + [6-8]\d| + 9\d{1,2} )| [2-9][6-9]\d )\d{6}| @@ -3131,7 +3095,7 @@ 7[13-579] )[6-9]\d{7} - \d{10} + \d{10,11} 1161234567 @@ -3438,7 +3402,7 @@ - [12-4]\d{8}| + [1-4]\d{8}| [89]\d{9,10} @@ -3573,14 +3537,9 @@ 2221234 - - - 6(?: - [0-3]\d| - [67][01] - )\d{4} - + + 6[0-367]\d{5} \d{7} 6221234 @@ -4719,7 +4678,7 @@ + nationalPrefixForParsing="(19(?:0[0-2468]|19|66|77))" carrierCodeFormattingRule="$CC $FG"> @@ -4768,17 +4727,21 @@ 9001234567 + + 210[0-6]\d{4}| 40(?: - 00\d{4}| + [04]0\d{4}| 10[0-3]\d{3}| 2(?: 00\d| 900 )\d{2}| 3[01]\d{4}| - 5\d{5} - ) + 5\d{5}| + 70[01]\d{3} + )| + 5100\d{4} \d{8} 40001234 @@ -4789,29 +4752,34 @@ 1(?: 0(?: 00| + 15| 2[2-4679] )| 1(?: 1[0-35-9]| 37| - 46| + [46]6| 75| 8[79]| 9[0-379] )| 2(?: - 12| - 22| - 34 + 00| + [12]2| + 34| + 55 )| 333| 400| - 55[15]| + 5(?: + 15| + 5[15]| + ) 693| 7(?: 00| - 1[78]| - 22| + 1[789]| + 2[02]| [67]7 ) ) @@ -4856,11 +4824,13 @@ 2[1-4]\d{5,6}| 3(?: 1\d{6}| - [23]\d{4,6})| + [23]\d{4,6} + )| 4(?: [125]\d{5,6}| [36]\d{6}| - [78]\d{4,6})| + [78]\d{4,6} + )| 7\d{6,7} 71234567 @@ -4870,9 +4840,21 @@ \d{8} 51234567 + + + 1(?: + 1(?: + 6111| + 8 + )| + 40 + ) + + \d{3,6} + 140 + - - 10[56] + 10[456] \d{3} 106 @@ -5018,7 +5000,7 @@ 22345678 - + 9[5-79]\d{6} 96123456 @@ -5374,6 +5356,26 @@ $1 $2 $3 + + 181 + $1 $2 + + + + 18500 + $1 $2 + + + 18[68] + $1 $2 + + + 18[2-579] + $1 $2 + 700 $1 $2 $3 @@ -5482,6 +5484,19 @@ \d{11} 70012345678 + + + + 18(?: + 1\d{5,11}| + [2-9]\d{8} + ) + + \d{8,14} + 18500123456 + 11[02] \d{3} @@ -5493,26 +5508,17 @@ - - $1 $2 $3 - $1 $2 $3 $4 - - [1-8]\d{5,7} - \d{6,8} + [27]\d{7} + \d{8} - (?: - 1[05]| - [2-5]\d - )\d{4}| 2(?: 1[2-5]| 7[45]| @@ -5521,7 +5527,7 @@ 21360003 - (?:77)?[6-8]\d{5} + 77[6-8]\d{5} 77831001 @@ -5933,7 +5939,7 @@ - + [369]| 4[3-8]| @@ -6098,7 +6104,7 @@ 1(?: 0[0169]| 1[124]| - 2[0278]| + 2[0-278]| 5[0-2] )| [89]00 @@ -6115,9 +6121,12 @@ $1 $2 $3 - + - 13| + 1(?: + 3| + 5[23] + )| [4-6]| [89][2-9] @@ -6134,34 +6143,44 @@ \d{5,10} - + (?: - 1[35][23]| - 2[23]\d| - 3\d| + 1( + 3[23]\d| + 5[23] + )| + 2[2-4]\d{2}| + 3\d{2}| 4(?: - 0[2-4]| + 0[2-5]| [578][23]| 64 - )| + )\d| 5(?: - 0[234]| + 0[2-7]| [57][23] - )| - 6[24-689]3| + )\d| + 6[24-689]3\d| 8(?: - [28][2-4]| - 42| - 6[23] - )| + 2[2-57]| + 4[26]| + 6[237]| + 8[2-4] + )\d| 9(?: - [25]2| + 2[27]| 3[24]| - 6[23]| + 52| + 6[2356]| 7[2-4] - ) - )\d{6}| + )\d + )\d{5}| 1[69]\d{3} \d{5,9} @@ -6169,7 +6188,9 @@ + the old pattern for three months, so we support both here in the meantime. Adding the + extra prefix 121 from user reports that Mobinil has started allocating numbers + beginning with this prefix. --> 1(?: [0-246-9]| @@ -6178,7 +6199,7 @@ 1(?: 0[0169]| 1[124]| - 2[0278] + 2[0-278] )\d{7} \d{9,10} @@ -6361,7 +6382,7 @@ 4(?: 1[69]| 3[2-49]| - 4[0-23]| + 4[0-3]| 6[5-8] )| 5(?: @@ -7010,7 +7031,7 @@ 2[89]| 3[35-9]| 4[01]| - 5[0-347-9]| + 5[0-47-9]| [67]\d| 8[457-9]| 9[0146] @@ -7545,7 +7566,7 @@ 7640123456 + http://en.wikipedia.org/wiki/Non-geographic_telephone_numbers_in_the_United_Kingdom --> @@ -8048,13 +8069,26 @@ nationalPrefix="0" nationalPrefixFormattingRule="$NP$FG"> - $1 $2 $3 + [235] + $1 $2 $3 + + + 8 + $1 $2 - [235]\d{6,8} + + [235]\d{8}| + 8\d{7} + \d{7,9} + + 800\d{5} + \d{8} + 80012345 + 3(?: @@ -8103,7 +8137,14 @@ \d{9} 231234567 - + + + 800\d{5} + \d{8} + 80012345 + + 19[123]| @@ -8951,10 +8992,15 @@ 21234567 - [5-79]\d{7} + [569]\d{7} \d{8} 51234567 + + 7\d{7} + \d{8} + 71234567 + 800\d{6} \d{9} @@ -8996,6 +9042,7 @@ \d{8} + 2(?: 2(?: @@ -9004,7 +9051,8 @@ [23]\d| 4[056]| 5[57]| - 9[01] + 8[0146-9]| + 9[012] )| 4(?: 2|3-59]| @@ -9358,9 +9406,15 @@ + Where known, fixed mobile prefixes have been represented as Mobile. --> - 2[124]\d{7,8}| + 2(?: + 1(?: + [0-8]\d{6,7}| + 9\d{6} + )| + [24]\d{7,8} + )| (?: 2(?: [35][1-4]| @@ -9398,7 +9452,7 @@ 6[1-8] )| 6(?: - 19? | + 19?| [25]\d| 3[1-469]| 4[1-6] @@ -9413,7 +9467,7 @@ )| 9(?: 0[12]| - 1[0134-8]| + 1[013-8]| 2[0-479]| 5[125-8]| 6[23679]| @@ -9426,7 +9480,87 @@ 612345678 - 8[1-35-9]\d{7,9} + + + (?: + 2(?: + 1(?: + 3[145]| + 4[01]| + 5[1-469]| + 60| + 8[0359]| + 9\d + )| + 2(?: + 88| + 9[1256] + )| + 3[1-4]9| + 4(?: + 36| + 91 + )| + 5(?: + 1[349]| + [2-4]9 + )| + 6[0-7]9| + 7(?: + [1-36]9| + 4[39] + )| + 8[1-5]9| + 9[1-48]9 + )| + 3(?: + 19[1-3]| + 2[12]9| + 3[13]9| + 4(?: + 1[69]| + 39 + )| + 5[14]9| + 6(?: + 1[69]| + 2[89] + )| + 709 + )| + 4[13]19| + 5(?: + 1(?: + 19| + 8[39] + )| + 4[129]9| + 6[12]9 + )| + 6(?: + 19[12]| + 2(?: + [23]9| + 77 + ) + )| + 7(?: + 1[13]9| + 2[15]9| + 419| + 5(?: + 1[89]| + 29 + )| + 6[15]9| + 7[178]9 + ) + )\d{5,6}| + 8[1-35-9]\d{7,9} + \d{9,11} 812345678 @@ -10242,8 +10376,10 @@ @@ -10253,8 +10389,8 @@ 33| 4[04]| 79 - )[2-6]\d{7}| - 80[2-46]\d{7}| + )[2-7]\d{7}| + 80[2-467]\d{7}| (?: 1(?: 2[0-249]| @@ -10327,7 +10463,7 @@ 8[34]| 91 ) - )[2-6]\d{6}| + )[2-7]\d{6}| (?: (?: 1(?: @@ -10384,9 +10520,8 @@ 2[2457]| 3[2-4]| 4[235-7]| - 5[2-689]| + [57][2-689]| 6[24-58]| - 7[23-689]| 8[1-6] )| 8(?: @@ -10416,7 +10551,7 @@ [013-8]\d ) ) - )[2-6]\d{5} + )[2-7]\d{5} \d{6,10} 1123456789 @@ -11742,7 +11877,7 @@ 9[1-578] )| 2(?: - 2[034-9]| + 2[03-9]| 3[3-58]| 4[0-468]| 5[04-8]| @@ -11789,7 +11924,7 @@ 9(?: [23]0| 4[02-46-9]| - 5[0245-79]| + 5[024-79]| 6[4-9]| 7[2-47-9]| 8[02-7]| @@ -11884,7 +12019,7 @@ 9[2-8] )| 3(?: - 7[2-56]| + 7[2-6]| [3-6][2-9]| 8[2-5] )| @@ -11904,7 +12039,7 @@ 9(?: [23]0| 4[02-46-9]| - 5[0245-79]| + 5[024-79]| 6[4-9]| 7[2-47-9]| 8[02-7]| @@ -12039,7 +12174,7 @@ 9(?: [23]0| 4[02-46-9]| - 5[0245-79]| + 5[024-79]| 6[4-9]| 7[2-47-9]| 8[02-7]| @@ -12181,7 +12316,7 @@ 9(?: [23]0| 4[02-46-9]| - 5[0245-79]| + 5[024-79]| 6[4-9]| 7[2-47-9]| 8[02-7]| @@ -12202,7 +12337,7 @@ 1| 2(?: 23| - 5[5-89]| + 5[5-9]| 64| 78| 8[39]| @@ -12482,6 +12617,7 @@ + @@ -12500,32 +12636,42 @@ - 20\d{4,7}| - [4-9]\d{5,9} + 20\d{6,7}| + [4-9]\d{6,9} - \d{4,10} + \d{5,10} + - (?: - 20| - 4[0-6]| - 5\d| - 6[0-24-9] - )\d{4,7} + 20\d{6,7}| + 4(?: + [013]\d{7}| + [24-6]\d{5,7} + )| + 5(?: + [0-36-8]\d{5,7}| + [459]\d{5} + )| + 6(?: + [08]\d{5}| + [14-79]\d{5,7}| + 2\d{7} + ) - \d{4,9} + \d{5,9} 202012345 - 7(?: - 0[0-5]| + 0[0-8]| [123]\d| - 5[0-4]| + 5[0-5]| 7[0-5]| - 8[6-9] + 8[5-9] )\d{6} \d{9} @@ -12533,32 +12679,26 @@ - 800[245-8]\d{5,6} + 800[24-8]\d{5,6} \d{9,10} 800223456 - - 9(?: - 00[2-578]| - 11\d - )\d{5} - + 900[02-578]\d{5} \d{9} 900223456 + 1(?: - 0[089]| + 0[09]| 1(?: [06]| - 99 + 9[0-2579] )| - 2[123]| - 3[013]| - 4[14]| - 501 + 2[13]| + 3[01] ) \d{3,4} @@ -12602,7 +12742,7 @@ - [356-8]\d{8,9} + [35-8]\d{8,9} \d{5,10} @@ -12733,7 +12873,7 @@ (?: 1[0-35-9]| 6[6-9]| - 7[06-89] + 7[06-9] )[1-9]| 8(?: 0[89]| @@ -13045,6 +13185,10 @@ nationalPrefix="0" nationalPrefixForParsing="0(8[1-46-8]|85\d{2})?" nationalPrefixFormattingRule="$NP$FG" carrierCodeFormattingRule="$NP$CC-$FG"> + + 11[29] + $1 + 1(?: @@ -13289,7 +13433,7 @@ (?: 5(?: - 0[0-26]| + 0[0-2568]| 5\d )| 6(?: @@ -13349,7 +13493,11 @@ [3589]\d{9} \d{7}(?:\d{3})? + + 345(?: 2(?: @@ -13363,6 +13511,7 @@ 40 )| 7(?: + 4[35-79]| 6[6-9]| 77 )| @@ -13370,8 +13519,7 @@ 00| 1[45]| 25| - 4[89]| - 88 + [48]8 )| 9(?: 14| @@ -13382,24 +13530,33 @@ 3452221234 + 345(?: - 32[3-79]| + 32[1-9]| 5(?: - 1[467]| + 1[67]| 2[5-7]| - 4[5-9] + 4[6-8]| + 76 )| 9(?: - 1[679]| - 2[4-9]| - 3[89] + 1[67]| + 2[3-9]| + 3[689] ) )\d{4} \d{10} 3453231234 + + 345849\d{4} + \d{10} + 3458491234 + 8(?: @@ -13673,7 +13830,7 @@ [89][01]| 7(?: [01]| - 6[01346-9]) + 6[013-9]) $1 $2 $3 @@ -13701,7 +13858,7 @@ 3\d| 7(?: [01]\d| - 6[01346-9] + 6[013-9] ) )\d{5} @@ -14245,7 +14402,7 @@ - [23-5]| + [2-5]| 7[1-9]| [89](?: [1-9]| @@ -14256,7 +14413,7 @@ - [23-5]| + [2-5]| 7[1-9]| [89](?: [1-9]| @@ -14625,12 +14782,15 @@ 520123456 + 6(?: - 0[0-36]| + 0[0-6]| [14-7]\d| - 2[236]| - 3[348]| + 2[23679]| + 3[03458]| + 80| 99 )\d{6} @@ -14745,7 +14905,7 @@ - [256-9]\d{7} + [25-9]\d{7} \d{8} @@ -15149,12 +15309,13 @@ \d{8} + (?: 2(?: [23]\d| 5[125]| - 61 + 6[01] )| 3(?: 1[3-6]| @@ -16536,7 +16697,7 @@ 17| 2(?: [0189]\d| - [23-6]| + [2-6]| 7\d? )| 3(?: @@ -16773,9 +16934,9 @@ 20201234 - - 9[0134678]\d{6} + + 9[0-46-9]\d{6} 93123456 @@ -17382,6 +17543,7 @@ preferredInternationalPrefix="00" nationalPrefix="0" nationalPrefixFormattingRule="$NP$FG"> + [3467]| @@ -17389,45 +17551,52 @@ $1-$2 $3 + + + 240 + 2409 + 24099 + $1 $2 + - - + + 21 $1 $2 $3 + + + + 2(?: + 1[1-9]| + [69]| + 7[0-35-9] + )| + 86 + + $1 $2 $3 + - - 22 + latter. We follow the same pattern for 020 (Orcon) and 028 (mixed) numbers. --> + + 2[028] $1 $2 $3 - - - + + - 2[0247-9]| + 2(?: + 10| + 74 + )| 5| - [89]00 + [89]0 $1 $2 $3 - - - 2[0169]|86 - $1 $2 $3 - - - - 240 - 2409 - 24099 - $1 $2 - @@ -17450,26 +17619,25 @@ 32345678 - + 2(?: - [079]\d{7}| + [028]\d{7,8}| 1(?: 0\d{5,7}| [12]\d{5,6}| [3-9]\d{5} )| - [28]\d{7,8}| - 4[1-9]\d{6} + [79]\d{7} ) \d{8,10} 211234567 - [28]6\d{6,7} - \d{8,9} - 26123456 + [28]6\d{6,7} + \d{8,9} + 26123456 - @@ -19646,45 +19812,16 @@ \d{6,7} - - - (?: - 2(?: - 55[0-5]| - 78[013] - )| - 4(?: - 2(?: - 0[589]| - 1[03-9]| - [2-9]\d - )| - [346]\d{2} - ) - )\d{3} - + + 4[2-46]\d{5} \d{7} 4217123 - - - 2(?: - 5(?: - [0-46-9]\d| - 5[6-9] - )| - 7(?: - [0-79]\d| - 8[24-9] - )| - 8\d{2} - )\d{3} - + + 2[5-8]\d{5} \d{7} 2510123 @@ -19895,7 +20032,7 @@ 4(?: [0246]\d{5,7}| (?: - 1[01-8]| + 1[0-8]| 3[0135]| 5[14-79]| 7[0-246-9]| @@ -20387,9 +20524,9 @@ nationalPrefix="0" nationalPrefixFormattingRule="($NP$FG)"> - - $1 $2 - + + $1 $2 + [2-578]\d{7} @@ -20402,16 +20539,17 @@ + further information about Datatel can be found. Adding prefix 79 since it was launched + by Airtel on Feb 2nd 2012. --> (?: 25| 3[03]| 44| 5[056]| - 7[6-8]| + 7[6-9]| 88 - )[1-9]\d{5} + )\d{6} 25123456 @@ -20526,7 +20664,7 @@ + 3[49], 4[7-9], 7[4-7], 8[2-9] and 9\d. --> 7(?: 0[1256]0| @@ -20542,8 +20680,7 @@ )| 7(?: 01| - [12-79]\d| - 8[0139] + [1-9]\d ) )\d{5} @@ -22265,7 +22402,7 @@ \d{5,9} - + 20(?: [014]\d{2}| @@ -22707,7 +22844,7 @@ )| 4(?: 2\d| - 3[1-4579]| + 3[1-579]| 7[1-79] )| 5(?: