Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #234 from EmicoEcommerce/bug/xss-issues
Browse files Browse the repository at this point in the history
Bug/xss issues
  • Loading branch information
Hnto authored Mar 22, 2022
2 parents fd5b60b + 7687780 commit 5ea7cde
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Model/Catalog/Layer/Url/Strategy/PathSlugStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,11 @@ public function getOriginalUrl(MagentoHttpRequest $request): string
if ($mode) {
$query['product_list_mode'] = $mode;
}
return $this->magentoUrl->getDirectUrl($twOriginalUrl, ['_query' => $query]);

return filter_var(
$this->magentoUrl->getDirectUrl($twOriginalUrl, ['_query' => $query]),
FILTER_SANITIZE_URL
);
}

return $this->getCurrentUrl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ protected function getCurrentQueryUrl(MagentoHttpRequest $request, array $query)
$params['_escape'] = false;

if ($originalUrl = $request->getQuery('__tw_original_url')) {
return $this->url->getDirectUrl($originalUrl, $params);
return $this->url->getDirectUrl(filter_var($originalUrl, FILTER_SANITIZE_ENCODED), $params);
}
return $this->url->getUrl('*/*/*', $params);
}
Expand Down
10 changes: 9 additions & 1 deletion Model/FilterFormInputProvider/ToolbarInputProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class ToolbarInputProvider implements FilterFormInputProviderInterface
Toolbar::PAGE_PARM_NAME
];

public const TOOLBAR_INPUTS_NO_ENCODING = [
Toolbar::ORDER_PARAM_NAME
];

/**
* @var MagentoHttpRequest
*/
Expand All @@ -46,7 +50,11 @@ public function getFilterFormInput()
$input = [];
foreach (self::TOOLBAR_INPUTS as $toolbarInput) {
if ($toolbarInputValue = $this->request->getParam($toolbarInput)) {
$input[$toolbarInput] = $toolbarInputValue;
if (in_array($toolbarInput, self::TOOLBAR_INPUTS_NO_ENCODING)) {
$input[$toolbarInput] = $toolbarInputValue;
continue;
}
$input[$toolbarInput] = filter_var($toolbarInputValue, FILTER_SANITIZE_ENCODED);
}
}

Expand Down

0 comments on commit 5ea7cde

Please sign in to comment.