Skip to content

Commit

Permalink
Merge pull request from GHSA-5v44-7647-xfw9
Browse files Browse the repository at this point in the history
Cast ids into int
  • Loading branch information
PierreRambaud committed Dec 3, 2020
2 parents 3a2601f + 6d80c77 commit 7c2033d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions controllers/front/CommentGrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public function display()
return $this->ajaxRender(null);
}

$idProducts = array_unique(array_map('intval', $idProducts));

$productCommentRepository = $this->context->controller->getContainer()->get('product_comment_repository');

$productsCommentsNb = $productCommentRepository->getCommentsNumberForProducts($idProducts, Configuration::get('PRODUCT_COMMENTS_MODERATE'));
Expand Down
4 changes: 2 additions & 2 deletions controllers/front/ListComments.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class ProductCommentsListCommentsModuleFrontController extends ModuleFrontContro
{
public function display()
{
$idProduct = Tools::getValue('id_product');
$page = Tools::getValue('page', 1);
$idProduct = (int) Tools::getValue('id_product');
$page = (int) Tools::getValue('page', 1);
$isLastNameAnynomus = Configuration::get('PRODUCT_COMMENTS_ANONYMISATION');
/** @var ProductCommentRepository $productCommentRepository */
$productCommentRepository = $this->context->controller->getContainer()->get('product_comment_repository');
Expand Down
2 changes: 1 addition & 1 deletion productcomments.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ protected function _postProcess()
$comment->delete();
} elseif (Tools::isSubmit('submitEditCriterion')) {
$criterion = new ProductCommentCriterion((int) Tools::getValue('id_product_comment_criterion'));
$criterion->id_product_comment_criterion_type = Tools::getValue('id_product_comment_criterion_type');
$criterion->id_product_comment_criterion_type = (int) Tools::getValue('id_product_comment_criterion_type');
$criterion->active = Tools::getValue('active');

$languages = Language::getLanguages();
Expand Down
4 changes: 2 additions & 2 deletions src/Repository/ProductCommentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function getAverageGrades(array $productIds, $validatedOnly)
$count = count($productIds);

foreach ($productIds as $index => $id) {
$esqID = pSQL($id);
$esqID = (int) $id;

$sql .= ' SUM(IF(id_product = ' . $esqID . ' AND deleted = 0';
if ($validatedOnly) {
Expand Down Expand Up @@ -247,7 +247,7 @@ public function getCommentsNumberForProducts(array $productIds, $validatedOnly)
$count = count($productIds);

foreach ($productIds as $index => $id) {
$esqID = pSQL($id);
$esqID = (int) $id;

$sql .= ' SUM(IF(id_product = ' . $esqID . ' AND deleted = 0';
if ($validatedOnly) {
Expand Down

0 comments on commit 7c2033d

Please sign in to comment.