mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 07:56:16 +00:00
phone number refinements
This commit is contained in:
parent
1540b3f8fe
commit
06bb1cd347
@ -142,8 +142,8 @@ final public class CorrelationAttributeNormalizer {
|
||||
* Verify it is only numbers and '+'. Strip spaces, dashes, and parentheses.
|
||||
*/
|
||||
private static String normalizePhone(String data) throws CorrelationAttributeNormalizationException {
|
||||
String phoneNumber = data.replaceAll("[^0-9\\+]", "");
|
||||
if(phoneNumber.matches("\\+?[0-9]+")){
|
||||
if(data.matches("\\+?[0-9()\\-\\s]+")){
|
||||
String phoneNumber = data.replaceAll("[^0-9\\+]", "");
|
||||
return phoneNumber;
|
||||
} else {
|
||||
throw new CorrelationAttributeNormalizationException(String.format("Data was expected to be a valid phone number: %s", data));
|
||||
|
@ -279,13 +279,13 @@ public class CorrelationAttributeNormalizerTest extends NbTestCase {
|
||||
}
|
||||
try {
|
||||
CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, badPnEight);
|
||||
//fail("This should have thrown an exception."); //this will eventually pass when we do a better job at this
|
||||
fail("This should have thrown an exception.");
|
||||
} catch (CorrelationAttributeNormalizationException ex) {
|
||||
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
|
||||
}
|
||||
try {
|
||||
CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, badPnNine);
|
||||
//fail("This should have thrown an exception."); //this will eventually pass when we do a better job at this
|
||||
fail("This should have thrown an exception.");
|
||||
} catch (CorrelationAttributeNormalizationException ex) {
|
||||
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user