Skip to content

Commit 7be02dc

Browse files
committed
Query escape rebuild to support non Latin character sets
1 parent a371f01 commit 7be02dc

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/DSL/QueryBuilder.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,21 +247,18 @@ private static function _parseParams($key, $value): string
247247

248248
}
249249

250-
public static function _escape($string): string
250+
251+
private static function _escape($value)
251252
{
252-
//+ - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ /
253-
$stripped = preg_replace('/\W/', '\\\\$0', $string);
254-
255-
//Put the spaces back;
256-
$stripped = str_replace('\ ', ' ', $stripped);
257-
//Edge cases
258-
$stripped = str_replace('\&\&', '\&&', $stripped);
259-
$stripped = str_replace('\|\|', '\||', $stripped);
260-
261-
return $stripped;
253+
$specialChars = ['+', '-', '=', '&&', '||', '>', '<', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', '\\'];
254+
foreach ($specialChars as $char) {
255+
$value = str_replace($char, "\\".$char, $value);
256+
}
262257

258+
return $value;
263259
}
264260

261+
265262
private function _buildQuery($wheres): array
266263
{
267264
if (!$wheres) {

0 commit comments

Comments
 (0)