Skip to content

Commit

Permalink
Merge pull request #1551 from craftcms/bugfix/1542-escape-match-values
Browse files Browse the repository at this point in the history
escape match value for the query
  • Loading branch information
angrybrad authored Nov 27, 2024
2 parents 2f1786d + 84be10c commit e2a946b
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/fields/CalendarEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use craft\feedme\base\FieldInterface;
use craft\feedme\helpers\DataHelper;
use craft\feedme\Plugin;
use craft\helpers\Db;
use craft\helpers\Json;
use Solspace\Calendar\Elements\Event as EventElement;

Expand Down Expand Up @@ -124,7 +125,7 @@ public function parseField(): mixed
$criteria['status'] = null;
$criteria['typeId'] = $typeIds;
$criteria['limit'] = $limit;
$criteria[$match] = $dataValue;
$criteria[$match] = Db::escapeParam($dataValue);

Craft::configure($query, $criteria);

Expand Down
2 changes: 1 addition & 1 deletion src/fields/Categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function parseField(): mixed

$criteria['status'] = null;
$criteria['limit'] = $limit;
$criteria[$match] = $dataValue;
$criteria[$match] = Db::escapeParam($dataValue);

Craft::configure($query, $criteria);

Expand Down
2 changes: 1 addition & 1 deletion src/fields/CommerceProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function parseField(): mixed
$criteria['status'] = null;
$criteria['typeId'] = $typeIds;
$criteria['limit'] = $limit;
$criteria[$match] = $dataValue;
$criteria[$match] = Db::escapeParam($dataValue);

Craft::configure($query, $criteria);

Expand Down
3 changes: 2 additions & 1 deletion src/fields/CommerceVariants.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use craft\feedme\base\FieldInterface;
use craft\feedme\helpers\DataHelper;
use craft\feedme\Plugin;
use craft\helpers\Db;
use craft\helpers\Json;

/**
Expand Down Expand Up @@ -128,7 +129,7 @@ public function parseField(): mixed
$criteria['status'] = null;
$criteria['typeId'] = $typeIds;
$criteria['limit'] = $limit;
$criteria[$match] = $dataValue;
$criteria[$match] = Db::escapeParam($dataValue);

Craft::configure($query, $criteria);

Expand Down
3 changes: 2 additions & 1 deletion src/fields/DigitalProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use craft\feedme\base\FieldInterface;
use craft\feedme\helpers\DataHelper;
use craft\feedme\Plugin;
use craft\helpers\Db;
use craft\helpers\Json;

/**
Expand Down Expand Up @@ -129,7 +130,7 @@ public function parseField(): mixed
$criteria['status'] = null;
$criteria['typeId'] = $typeIds;
$criteria['limit'] = $limit;
$criteria[$match] = $dataValue;
$criteria[$match] = Db::escapeParam($dataValue);

Craft::configure($query, $criteria);

Expand Down
2 changes: 1 addition & 1 deletion src/fields/Entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function parseField(): mixed

$criteria['status'] = null;
$criteria['limit'] = $limit;
$criteria[$match] = $dataValue;
$criteria[$match] = Db::escapeParam($dataValue);

Craft::configure($query, $criteria);

Expand Down
2 changes: 1 addition & 1 deletion src/fields/Tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function parseField(): mixed
$criteria['status'] = null;
$criteria['groupId'] = $groupId;
$criteria['limit'] = $limit;
$criteria[$match] = $dataValue;
$criteria[$match] = Db::escapeParam($dataValue);

Craft::configure($query, $criteria);

Expand Down
2 changes: 1 addition & 1 deletion src/fields/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function parseField(): mixed
$ids = [];
$criteria['status'] = null;
$criteria['limit'] = $limit;
$criteria[$match] = $dataValue;
$criteria[$match] = Db::escapeParam($dataValue);

// If the only source for the Users field is "admins" we don't have to bother with this query.
if (!($isAdmin && empty($groupIds) && empty($customSources))) {
Expand Down

0 comments on commit e2a946b

Please sign in to comment.