Skip to content

Commit fb61572

Browse files
committed
Query escape rebuild to support non Latin character sets
1 parent ee912cb commit fb61572

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,9 +1468,3 @@ once and not update immediately or won't need to search for the record immediate
14681468
### Unsupported Eloquent methods
14691469

14701470
`upsert()`, `distinct()`, `groupBy()`, `groupByRaw()`
1471-
1472-
Acknowledgements
1473-
-------------
1474-
1475-
This package was inspired by [jenssegers/laravel-mongodb](https://github.com/jenssegers/laravel-mongodb), a MongoDB
1476-
implementation of Laravel's Eloquent ORM - Thank you!

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): string
247247

248248
}
249249

250-
public static function _escape($string): 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): array

0 commit comments

Comments
 (0)