-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
where
parameter and deprecate filters
parameter
- Loading branch information
Showing
13 changed files
with
332 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,9 @@ | |
|
||
use UnexpectedValueException; | ||
|
||
/** | ||
* @deprecated | ||
*/ | ||
class Filter | ||
{ | ||
public const OPERATOR_EQ = 'eq'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Smile\GdprDump\Dumper\Config\Validation; | ||
|
||
use TheSeer\Tokenizer\Token; | ||
|
||
class WhereExprValidator | ||
{ | ||
private QueryValidator $queryValidator; | ||
|
||
public function __construct() | ||
{ | ||
$this->queryValidator = new QueryValidator(['select']); | ||
} | ||
|
||
/** | ||
* Validate the where expression. | ||
*/ | ||
public function validate(string $expr): void | ||
{ | ||
$openedBrackets = 0; | ||
|
||
$this->queryValidator->validate($expr, function (Token $token) use ($expr, &$openedBrackets): void { | ||
// Disallow using a closing bracket if there is no matching opening bracket -> prevents SQL injection | ||
if ($token->getName() === 'T_OPEN_BRACKET') { | ||
++$openedBrackets; | ||
return; | ||
} | ||
|
||
if ($token->getName() === 'T_CLOSE_BRACKET') { | ||
if ($openedBrackets === 0) { | ||
throw new ValidationException(sprintf('Unmatched closing bracket found in query "%s".', $expr)); | ||
} | ||
|
||
--$openedBrackets; | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.