From 1f1f66cf3a3e9a28ff072947f92e5fc6d79d0a81 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Mon, 27 Jan 2025 10:58:47 +0530 Subject: [PATCH] FIX_EXCEL_SANTIZE_HELPER_IMPROVED --- app/Helpers/ExcelSanitizeHelper.php | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/app/Helpers/ExcelSanitizeHelper.php b/app/Helpers/ExcelSanitizeHelper.php index 67aaa55e..5c2836a7 100644 --- a/app/Helpers/ExcelSanitizeHelper.php +++ b/app/Helpers/ExcelSanitizeHelper.php @@ -1,4 +1,5 @@ $value) { if (is_array($value)) { $cleanData[$key] = self::sanitizeArrayData($value); // Recursive call for nested arrays } elseif (is_string($value)) { // Remove non-printable characters and trim whitespace from strings - $cleanData[$key] = trim(str_replace(self::$nonPrintableChars, '', $value)); + $cleanData[$key] = trim(preg_replace(self::$nonPrintablePattern, '', $value)); } else { $cleanData[$key] = $value; // Keep non-string/non-array data as is } } - return $cleanData; } catch (\Exception $e) { // Log the error and the problematic data for debugging