Skip to content

Commit

Permalink
Merge branch 'next-36872/auto-imported-from-github' into 'trunk'
Browse files Browse the repository at this point in the history
NEXT-36872 - Add fragment path snippet to url whitelist

See merge request shopware/6/product/platform!14103
  • Loading branch information
Stefan Sluiter committed Jul 15, 2024
2 parents b45d497 + b9c5496 commit 8ad1fef
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Add path required to run profiler to storefront url whitelist
issue: NEXT-36872
author: Benedikt Brunner
author_email: benedikt.brunner@pickware.de
author_github: Benedikt-Brunner
---
___
# Storefront
* Added the `/_fragment` url-snippet to the allow list of the `RequestTransformer`
5 changes: 3 additions & 2 deletions src/Storefront/Framework/Routing/RequestTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ class RequestTransformer implements RequestTransformerInterface
/**
* @var array<string>
*/
private array $whitelist = [
private array $allowedList = [
'/_wdt/',
'/_profiler/',
'/_error/',
'/payment/finalize-transaction',
'/installer',
'/_fragment/',
];

/**
Expand Down Expand Up @@ -243,7 +244,7 @@ private function isSalesChannelRequired(string $pathInfo): bool
}
}

foreach ($this->whitelist as $prefix) {
foreach ($this->allowedList as $prefix) {
if (str_starts_with($pathInfo, $prefix)) {
return false;
}
Expand Down
31 changes: 31 additions & 0 deletions tests/unit/Storefront/Framework/Routing/RequestTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,36 @@ public static function notRequiredSalesChannelProvider(): iterable
'registeredApiPrefixes' => ['api'],
'requestUri' => 'http://shopware.com//api//',
];

// Allowedlist paths:
yield '_wdt case' => [
'registeredApiPrefixes' => ['api'],
'requestUri' => 'http://shopware.com/_wdt/',
];

yield '_profiler case' => [
'registeredApiPrefixes' => ['api'],
'requestUri' => 'http://shopware.com/_profiler/',
];

yield '_error case' => [
'registeredApiPrefixes' => ['api'],
'requestUri' => 'http://shopware.com/_error/',
];

yield 'payment finalize-transaction case' => [
'registeredApiPrefixes' => ['api'],
'requestUri' => 'http://shopware.com/payment/finalize-transaction/',
];

yield 'installer case' => [
'registeredApiPrefixes' => ['api'],
'requestUri' => 'http://shopware.com/installer',
];

yield '_fragment case' => [
'registeredApiPrefixes' => ['api'],
'requestUri' => 'http://shopware.com/_fragment/',
];
}
}

0 comments on commit 8ad1fef

Please # to comment.