Skip to content

Commit 90bf91d

Browse files
committed
Corrected blacklist patterns
1 parent 7a82782 commit 90bf91d

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010
use Magento\MediaGalleryApi\Model\Directory\IsBlacklistedInterface;
1111

1212
/**
13-
* Directories blacklisted for media gallery. This class should be used for DI configuration.
14-
*
15-
* Please use the interface in the code (for constructor injection) instead of this implementation.
16-
*
17-
* @api
13+
* Check if the path is blacklisted for media gallery. Directory path may be blacklisted if it's reserved by the system
1814
*/
1915
class IsBlacklisted implements IsBlacklistedInterface
2016
{
17+
const XML_PATH_BLACKLIST_PATTERNS = 'blacklist/patterns';
18+
2119
/**
2220
* @var Config
2321
*/
@@ -26,7 +24,8 @@ class IsBlacklisted implements IsBlacklistedInterface
2624
/**
2725
* @param Config $config
2826
*/
29-
public function __construct(Config $config) {
27+
public function __construct(Config $config)
28+
{
3029
$this->config = $config;
3130
}
3231

@@ -38,7 +37,7 @@ public function __construct(Config $config) {
3837
*/
3938
public function execute(string $path): bool
4039
{
41-
foreach ($this->config->get('blacklist/patterns') as $pattern) {
40+
foreach ($this->config->get(self::XML_PATH_BLACKLIST_PATTERNS) as $pattern) {
4241
if (empty($pattern)) {
4342
continue;
4443
}

app/code/Magento/MediaGallery/etc/directory.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_MediaGallery:etc/directory.xsd">
99
<blacklist>
1010
<patterns>
11-
<pattern name="captcha">/pub\/media\/captcha/</pattern>
12-
<pattern name="catalog">/pub\/media\/catalog\/product/</pattern>
13-
<pattern name="customer">/pub\/media\/customer/</pattern>
14-
<pattern name="downloadable">/pub\/media\/downloadable/</pattern>
15-
<pattern name="import">/pub\/media\/import/</pattern>
16-
<pattern name="theme">/pub\/media\/theme/</pattern>
17-
<pattern name="theme_customization">/pub\/media\/theme_customization/</pattern>
18-
<pattern name="tmp">/pub\/media\/tmp/</pattern>
11+
<pattern name="captcha">/^captcha/</pattern>
12+
<pattern name="catalog">/^catalog\/product/</pattern>
13+
<pattern name="customer">/^customer/</pattern>
14+
<pattern name="downloadable">/^downloadable/</pattern>
15+
<pattern name="import">/^import/</pattern>
16+
<pattern name="theme">/^theme/</pattern>
17+
<pattern name="theme_customization">/^theme_customization/</pattern>
18+
<pattern name="tmp">/^tmp/</pattern>
1919
<pattern name="directories-with-dots">/^\./</pattern>
2020
</patterns>
2121
</blacklist>

0 commit comments

Comments
 (0)