Skip to content

Commit 8b8ccbc

Browse files
committed
Query escape rebuild to support non Latin character sets
1 parent 8a9c999 commit 8b8ccbc

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/DSL/QueryBuilder.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,19 +247,14 @@ private static function _parseParams($key, $value)
247247

248248
}
249249

250-
public static function _escape($string)
250+
public static function _escape($value): string
251251
{
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;
252+
$specialChars = ['"', '\\', '~', '^'];
253+
foreach ($specialChars as $char) {
254+
$value = str_replace($char, "\\".$char, $value);
255+
}
262256

257+
return $value;
263258
}
264259

265260
private function _buildQuery($wheres)

0 commit comments

Comments
 (0)