mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
fix: Escape like strings
This commit is contained in:
@@ -34,6 +34,8 @@ class FulltextGambit implements GambitInterface
|
|||||||
*/
|
*/
|
||||||
private function getUserSearchSubQuery($searchValue)
|
private function getUserSearchSubQuery($searchValue)
|
||||||
{
|
{
|
||||||
|
$searchValue = $this->users->escapeLikeString($searchValue);
|
||||||
|
|
||||||
return $this->users
|
return $this->users
|
||||||
->query()
|
->query()
|
||||||
->select('id')
|
->select('id')
|
||||||
|
@@ -102,6 +102,8 @@ class UserRepository
|
|||||||
* @param string $string
|
* @param string $string
|
||||||
* @param User|null $actor
|
* @param User|null $actor
|
||||||
* @return array
|
* @return array
|
||||||
|
*
|
||||||
|
* @deprecated remove in 2.0 (no longer used since https://github.com/flarum/core/pull/1878)
|
||||||
*/
|
*/
|
||||||
public function getIdsForUsername($string, User $actor = null)
|
public function getIdsForUsername($string, User $actor = null)
|
||||||
{
|
{
|
||||||
@@ -135,8 +137,10 @@ class UserRepository
|
|||||||
*
|
*
|
||||||
* @param string $string
|
* @param string $string
|
||||||
* @return string
|
* @return string
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
*/
|
*/
|
||||||
private function escapeLikeString($string)
|
public function escapeLikeString($string)
|
||||||
{
|
{
|
||||||
return str_replace(['\\', '%', '_'], ['\\\\', '\%', '\_'], $string);
|
return str_replace(['\\', '%', '_'], ['\\\\', '\%', '\_'], $string);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user