From b54a780cd6db8fc142711209350416d581874d09 Mon Sep 17 00:00:00 2001 From: Jimmy Li Date: Wed, 31 Jan 2024 14:53:45 -0800 Subject: [PATCH] Update PII regex and minor change to test inputs --- AutocompleteClient/FW/Logic/Worker/ConstructorIO.swift | 2 +- .../FW/Logic/Worker/ConstructorIOTests.swift | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/AutocompleteClient/FW/Logic/Worker/ConstructorIO.swift b/AutocompleteClient/FW/Logic/Worker/ConstructorIO.swift index 6bf70233..207fbe0e 100644 --- a/AutocompleteClient/FW/Logic/Worker/ConstructorIO.swift +++ b/AutocompleteClient/FW/Logic/Worker/ConstructorIO.swift @@ -1008,7 +1008,7 @@ public class ConstructorIO: CIOSessionManagerDelegate { let PIIPatterns = [ // Email - PIIPattern(pattern: #"^[\w\-+\\.]+@([\w-]+\.)+[\w-]{2,4}$"#, replaceBy: ""), + PIIPattern(pattern: #"[\w\-+\\.]+@([\w-]+\.)+[\w-]{2,4}"#, replaceBy: ""), // Phone PIIPattern(pattern: #"^(?:\+\d{11,12}|\+\d{1,3}\s\d{3}\s\d{3}\s\d{3,4}|\(\d{3}\)\d{7}|\(\d{3}\)\s\d{3}\s\d{4}|\(\d{3}\)\d{3}-\d{4}|\(\d{3}\)\s\d{3}-\d{4})$"#, replaceBy: ""), // Visa, Mastercard, Amex, Discover, JCB and Diners Club, regex source: https://www.regular-expressions.info/creditcard.html diff --git a/AutocompleteClientTests/FW/Logic/Worker/ConstructorIOTests.swift b/AutocompleteClientTests/FW/Logic/Worker/ConstructorIOTests.swift index a60be1c5..903b23a5 100644 --- a/AutocompleteClientTests/FW/Logic/Worker/ConstructorIOTests.swift +++ b/AutocompleteClientTests/FW/Logic/Worker/ConstructorIOTests.swift @@ -23,7 +23,12 @@ class ConstructorIOTests: XCTestCase { "test@test.io", "test@test.com.com", "test+100@test.com", - "test-100@test-test.io" + "test-100@test-test.io", + " test@test.io", + "test@test.com.com ", + " test.100@test.com.au ", + "text test.100@test.io text", + "test@test@test.com", // This string includes a valid email - test@test.com ] let phonePIIParams = [ @@ -77,7 +82,6 @@ class ConstructorIOTests: XCTestCase { "test123@.com.com", "test()*@test.com", "test@%*.com", - "test@test@test.com", "test@test", // Phone Number "123",