Skip to content

Commit 6daefc3

Browse files
committed
fix sanitizer
1 parent e8029b8 commit 6daefc3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Helpers/PostgresTextSanitizer.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Umbrellio\Postgres\Helpers;
66

7+
use Illuminate\Support\Facades\Log;
8+
79
class PostgresTextSanitizer
810
{
911
/**
@@ -20,8 +22,11 @@ public static function sanitize(?string $input): ?string
2022
}
2123

2224
// Удаляем управляющие символы, кроме: табуляция (\x09), \n (\x0A), \r (\x0D)
23-
$input = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/u', '', $input);
25+
$input1 = preg_replace_callback('/[\x00-\x1F]/', function ($match) {
26+
$ord = ord($match[0]);
27+
return in_array($ord, [9, 10, 13], true) ? $match[0] : '';
28+
}, $input);
2429

25-
return $input;
30+
return str_replace(array("\x00", "\x0"), '', $input1);
2631
}
2732
}

0 commit comments

Comments
 (0)