Skip to content

Commit

Permalink
Fix sql injection through the type and language parameter of the tran…
Browse files Browse the repository at this point in the history
…slation export
  • Loading branch information
carakas committed Mar 23, 2022
1 parent 1b38e33 commit 3710cbc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Backend/Modules/Locale/Actions/Export.php
Expand Up @@ -5,6 +5,7 @@
use Backend\Core\Engine\Base\ActionIndex as BackendBaseActionIndex;
use Backend\Core\Engine\Model as BackendModel;
use Backend\Core\Language\Language as BL;
use Backend\Core\Language\Locale;
use Backend\Modules\Locale\Engine\Model as BackendLocaleModel;
use Symfony\Component\HttpFoundation\Response;

Expand Down Expand Up @@ -47,7 +48,7 @@ private function buildQuery(): array
// create an array for the languages, surrounded by quotes (example: 'en')
$languages = [];
foreach ($this->filter['language'] as $key => $val) {
$languages[$key] = '\'' . $val . '\'';
$languages[$key] = '\'' . Locale::fromString($val) . '\'';
}

$query .= ' AND l.language IN (' . implode(',', $languages) . ')';
Expand All @@ -70,7 +71,9 @@ private function buildQuery(): array
// create an array for the types, surrounded by quotes (example: 'lbl')
$types = [];
foreach ($this->filter['type'] as $key => $val) {
$types[$key] = '\'' . $val . '\'';
if (in_array($val, BackendLocaleModel::TYPES)) {
$types[$key] = '\'' . $val . '\'';
}
}

$query .= ' AND l.type IN (' . implode(',', $types) . ')';
Expand Down

0 comments on commit 3710cbc

Please sign in to comment.