mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +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.
|
* Verify it is only numbers and '+'. Strip spaces, dashes, and parentheses.
|
||||||
*/
|
*/
|
||||||
private static String normalizePhone(String data) throws CorrelationAttributeNormalizationException {
|
private static String normalizePhone(String data) throws CorrelationAttributeNormalizationException {
|
||||||
String phoneNumber = data.replaceAll("[^0-9\\+]", "");
|
if(data.matches("\\+?[0-9()\\-\\s]+")){
|
||||||
if(phoneNumber.matches("\\+?[0-9]+")){
|
String phoneNumber = data.replaceAll("[^0-9\\+]", "");
|
||||||
return phoneNumber;
|
return phoneNumber;
|
||||||
} else {
|
} else {
|
||||||
throw new CorrelationAttributeNormalizationException(String.format("Data was expected to be a valid phone number: %s", data));
|
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 {
|
try {
|
||||||
CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, badPnEight);
|
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) {
|
} catch (CorrelationAttributeNormalizationException ex) {
|
||||||
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
|
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
CorrelationAttributeNormalizer.normalize(PHONE_TYPE_ID, badPnNine);
|
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) {
|
} catch (CorrelationAttributeNormalizationException ex) {
|
||||||
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
|
assertTrue(WE_EXPECT_AN_EXCEPTION_HERE, true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user