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 #131 from EmicoEcommerce/issue/127378-404-incorrec…
Browse files Browse the repository at this point in the history
…t-filter-urls

Dont match incorrect filter urls when they are structurally incorrect
  • Loading branch information
edwinljacobs authored Nov 11, 2020
2 parents 9928736 + 99e8d0b commit 08aba54
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/Model/Catalog/Layer/Url/Strategy/PathSlugStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,20 @@ public function match(MagentoHttpRequest $request)

$rewrite = current($rewrites);
$path = trim($request->getPathInfo(), '/');

$filterPath = str_replace($rewrite->getRequestPath(), '', $path);
$filterPathParts = explode('/', trim($filterPath, '/'));
if ((count($filterPathParts) %2) !== 0) {
/* In this case we dont have an even amount of path segments,
This cannot correspond to a filter in this model since the filters
are constructed as filterName/filterValue for each filter, note the two components
for each filter. Meaning that a correct filter path should have an even number of path parts
*/
return false;
}
// Set the filter params part of the URL as a separate request param.
// The request param filter_path is used to query tweakwise.
$request->setParam(
self::REQUEST_FILTER_PATH,
str_replace($rewrite->getRequestPath(), '', $path)
);

$request->setParam(self::REQUEST_FILTER_PATH, $filterPath);
$request->setAlias(
MagentoUrlInterface::REWRITE_REQUEST_PATH_ALIAS,
$path
Expand Down

0 comments on commit 08aba54

Please sign in to comment.