From c71ce59334aebde91c5e9b8d3de61213eb43a09a Mon Sep 17 00:00:00 2001 From: Debian Date: Wed, 19 Oct 2022 09:04:23 +0000 Subject: [PATCH] used the desired pattern to trim the magento customer name --- Controller/Index/Index.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Controller/Index/Index.php b/Controller/Index/Index.php index 54ec77d..8e923c8 100644 --- a/Controller/Index/Index.php +++ b/Controller/Index/Index.php @@ -1807,11 +1807,15 @@ private function _processCustomerData( $customerGroupId = $koganGroup->getId(); } + $regexPattern = '/(?:[^\p{L}\p{M}\,\-\_\.\'’`\s\d]){1,255}+/u'; + $matchedFirstName = preg_replace($regexPattern, '', (string)$addressBilling['firstname']); + $matchedLastName = preg_replace($regexPattern, '', (string)$addressBilling['lastname']); + $customer->setWebsiteId($websiteId); $customer->setStoreId($store->getId()); $customer->setEmail($email); - $customer->setFirstname((string)$addressBilling['firstname']); - $customer->setLastname((string)$addressBilling['lastname']); + $customer->setFirstname($matchedFirstName); + $customer->setLastname($matchedLastName); $customer->setPassword((string)sha1(uniqid())); if ($customerGroupId) { $customer->setGroupId($customerGroupId);