From a1ea5d753c81d8ea97c418012e3d68501c8a6e41 Mon Sep 17 00:00:00 2001 From: Hall Liu Date: Wed, 5 Dec 2018 13:57:42 -0800 Subject: [PATCH] Fix validation problem in PhoneNumberRange Regexes weren't matching empty strings (which are perfectly valid) for the various arguments in the ranges. Fix it so that they do match. Bug: 119675160 Test: GTS Change-Id: I4ea0f65b62af9fd35612e5261e01b2bea07c8ddc --- telephony/java/android/telephony/PhoneNumberRange.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/telephony/java/android/telephony/PhoneNumberRange.java b/telephony/java/android/telephony/PhoneNumberRange.java index d65156fd3ca24..dba803b2bc199 100644 --- a/telephony/java/android/telephony/PhoneNumberRange.java +++ b/telephony/java/android/telephony/PhoneNumberRange.java @@ -71,10 +71,10 @@ public final class PhoneNumberRange implements Parcelable { public PhoneNumberRange(@NonNull String countryCode, @NonNull String prefix, @NonNull String lowerBound, @NonNull String upperBound) { validateLowerAndUpperBounds(lowerBound, upperBound); - if (!Pattern.matches("[0-9]+", countryCode)) { + if (!Pattern.matches("[0-9]*", countryCode)) { throw new IllegalArgumentException("Country code must be all numeric"); } - if (!Pattern.matches("[0-9]+", prefix)) { + if (!Pattern.matches("[0-9]*", prefix)) { throw new IllegalArgumentException("Prefix must be all numeric"); } mCountryCode = countryCode; @@ -133,10 +133,10 @@ public final class PhoneNumberRange implements Parcelable { if (lowerBound.length() != upperBound.length()) { throw new IllegalArgumentException("Lower and upper bounds must have the same length"); } - if (!Pattern.matches("[0-9]+", lowerBound)) { + if (!Pattern.matches("[0-9]*", lowerBound)) { throw new IllegalArgumentException("Lower bound must be all numeric"); } - if (!Pattern.matches("[0-9]+", upperBound)) { + if (!Pattern.matches("[0-9]*", upperBound)) { throw new IllegalArgumentException("Upper bound must be all numeric"); } if (Integer.parseInt(lowerBound) > Integer.parseInt(upperBound)) {