From 06bb1cd3474a0de098abbf46cfd70a302d1664e5 Mon Sep 17 00:00:00 2001 From: Brian Sweeney Date: Thu, 6 Sep 2018 15:49:39 -0600 Subject: [PATCH] phone number refinements --- .../datamodel/CorrelationAttributeNormalizer.java | 4 ++-- .../datamodel/CorrelationAttributeNormalizerTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizer.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizer.java index f781ba5016..772e1c517e 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizer.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizer.java @@ -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)); diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizerTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizerTest.java index b7c2fcdfcb..76d28e7ea6 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizerTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizerTest.java @@ -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); }