Skip to content

Commit

Permalink
fix: filter values are not validated (#3795)
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed May 7, 2023
1 parent 48bde03 commit fda63bd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Query/SubscriptionFilterGambit.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@

use Flarum\Filter\FilterInterface;
use Flarum\Filter\FilterState;
use Flarum\Filter\ValidateFilterTrait;
use Flarum\Search\AbstractRegexGambit;
use Flarum\Search\SearchState;
use Flarum\User\User;
use Illuminate\Database\Query\Builder;

class SubscriptionFilterGambit extends AbstractRegexGambit implements FilterInterface
{
use ValidateFilterTrait;

protected function getGambitPattern()
{
return 'is:(follow|ignor)(?:ing|ed)';
Expand All @@ -33,8 +36,10 @@ public function getFilterKey(): string
return 'subscription';
}

public function filter(FilterState $filterState, string $filterValue, bool $negate)
public function filter(FilterState $filterState, $filterValue, bool $negate)
{
$filterValue = $this->asString($filterValue);

preg_match('/^'.$this->getGambitPattern().'$/i', 'is:'.$filterValue, $matches);

$this->constrain($filterState->getQuery(), $filterState->getActor(), $matches[1], $negate);
Expand Down

0 comments on commit fda63bd

Please sign in to comment.