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