Skip to content

Commit 8554a71

Browse files
authored
Merge pull request #76 from magento-commerce/MCLOUD-10226
MCLOUD-10226: Fix regexp cache tag validation
2 parents ddf4169 + 440222a commit 8554a71

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

patches.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,5 +396,10 @@
396396
">=2.3.4-p2 <2.3.7-p3 || >=2.4.0 <2.4.3": "MDVA-43443__parser_token_new_fix__2.3.4-p2.patch",
397397
">=2.4.3 <2.4.3-p2": "MDVA-43443__parser_token_new_fix__2.4.3.patch"
398398
}
399+
},
400+
"magento/framework": {
401+
"Fix regexp cache tag validation": {
402+
">=103.0.6 <103.0.7": "MCLOUD-10226__fix_regexp_cache_tag_validation__2.4.6.patch"
403+
}
399404
}
400405
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
diff -Naur a/vendor/magento/framework/Cache/Core.php b/vendor/magento/framework/Cache/Core.php
2+
--- a/vendor/magento/framework/Cache/Core.php 2023-02-23 14:11:04
3+
+++ b/vendor/magento/framework/Cache/Core.php 2023-04-14 11:54:58
4+
@@ -5,6 +5,10 @@ namespace Magento\Framework\Cache;
5+
*/
6+
namespace Magento\Framework\Cache;
7+
8+
+use Magento\Framework\Cache\Backend\Redis;
9+
+use Zend_Cache;
10+
+use Zend_Cache_Exception;
11+
+
12+
class Core extends \Zend_Cache_Core
13+
{
14+
/**
15+
@@ -124,6 +128,34 @@ class Core extends \Zend_Cache_Core
16+
{
17+
$tags = $this->_tags($tags);
18+
return parent::getIdsNotMatchingTags($tags);
19+
+ }
20+
+
21+
+ /**
22+
+ * Validate a cache id or a tag (security, reliable filenames, reserved prefixes...)
23+
+ *
24+
+ * Throw an exception if a problem is found
25+
+ *
26+
+ * @param string $string Cache id or tag
27+
+ * @throws Zend_Cache_Exception
28+
+ * @return void
29+
+ */
30+
+ protected function _validateIdOrTag($string)
31+
+ {
32+
+ if ($this->_backend instanceof Redis) {
33+
+ if (!is_string($string)) {
34+
+ Zend_Cache::throwException('Invalid id or tag : must be a string');
35+
+ }
36+
+ if (substr($string, 0, 9) == 'internal-') {
37+
+ Zend_Cache::throwException('"internal-*" ids or tags are reserved');
38+
+ }
39+
+ if (!preg_match('~^[a-zA-Z0-9_{}]+$~D', $string)) {
40+
+ Zend_Cache::throwException("Invalid id or tag '$string' : must use only [a-zA-Z0-9_{}]");
41+
+ }
42+
+
43+
+ return;
44+
+ }
45+
+
46+
+ parent::_validateIdOrTag($string);
47+
}
48+
49+
/**

src/Test/Functional/Acceptance/AcceptanceCest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public function testPatches(\CliTester $I, \Codeception\Example $data): void
4949
protected function patchesDataProvider(): array
5050
{
5151
return [
52-
['templateVersion' => '2.4.6', 'magentoVersion' => null],
52+
['templateVersion' => '2.4.6', 'magentoVersion' => '2.4.6'],
53+
['templateVersion' => '2.4.6', 'magentoVersion' => '2.4.6-p1'],
5354
];
5455
}
5556
}

0 commit comments

Comments
 (0)