-
Notifications
You must be signed in to change notification settings - Fork 6
/
MDVA-43443_EE_2.3.4_magento-framework.patch
150 lines (140 loc) · 5.38 KB
/
MDVA-43443_EE_2.3.4_magento-framework.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
diff --git a/Filter/DirectiveProcessor/DependDirective.php b/Filter/DirectiveProcessor/DependDirective.php
index f557f7465b5..83345acd6e5 100644
--- a/Filter/DirectiveProcessor/DependDirective.php
+++ b/Filter/DirectiveProcessor/DependDirective.php
@@ -32,9 +32,13 @@ class DependDirective implements DirectiveProcessorInterface
}
/**
- * @inheritdoc
+ * @param array $construction
+ * @param Template $filter
+ * @param array $templateVariables
+ *
+ * @return string
*/
- public function process(array $construction, Template $filter, array $templateVariables): string
+ private function resolve(array $construction, Template $filter, array $templateVariables): string
{
if (empty($templateVariables)) {
// If template processing
@@ -48,6 +52,16 @@ class DependDirective implements DirectiveProcessorInterface
}
}
+ /**
+ * @inheritdoc
+ */
+ public function process(array $construction, Template $filter, array $templateVariables): string
+ {
+ $result = $this->resolve($construction, $filter, $templateVariables);
+
+ return str_replace(['{', '}'], '', (string) $result);
+ }
+
/**
* @inheritdoc
*/
diff --git a/Filter/DirectiveProcessor/ForDirective.php b/Filter/DirectiveProcessor/ForDirective.php
index 2b51185b1b5..41cd58118fd 100644
--- a/Filter/DirectiveProcessor/ForDirective.php
+++ b/Filter/DirectiveProcessor/ForDirective.php
@@ -36,14 +36,13 @@ class ForDirective implements DirectiveProcessorInterface
}
/**
- * Filter the string as template.
- *
* @param array $construction
* @param Template $filter
* @param array $templateVariables
+ *
* @return string
*/
- public function process(array $construction, Template $filter, array $templateVariables): string
+ private function resolve(array $construction, Template $filter, array $templateVariables): string
{
if (!$this->isValidLoop($construction)) {
return $construction[0];
@@ -67,6 +66,16 @@ class ForDirective implements DirectiveProcessorInterface
return $construction[0];
}
+ /**
+ * @inheritdoc
+ */
+ public function process(array $construction, Template $filter, array $templateVariables): string
+ {
+ $result = $this->resolve($construction, $filter, $templateVariables);
+
+ return str_replace(['{', '}'], '', (string) $result);
+ }
+
/**
* Check if the matched construction is valid.
*
diff --git a/Filter/DirectiveProcessor/IfDirective.php b/Filter/DirectiveProcessor/IfDirective.php
index 7fedc7946f2..469dae71d06 100644
--- a/Filter/DirectiveProcessor/IfDirective.php
+++ b/Filter/DirectiveProcessor/IfDirective.php
@@ -32,9 +32,13 @@ class IfDirective implements DirectiveProcessorInterface
}
/**
- * @inheritdoc
+ * @param array $construction
+ * @param Template $filter
+ * @param array $templateVariables
+ *
+ * @return string
*/
- public function process(array $construction, Template $filter, array $templateVariables): string
+ private function resolve(array $construction, Template $filter, array $templateVariables): string
{
if (empty($templateVariables)) {
return $construction[0];
@@ -50,6 +54,16 @@ class IfDirective implements DirectiveProcessorInterface
}
}
+ /**
+ * @inheritdoc
+ */
+ public function process(array $construction, Template $filter, array $templateVariables): string
+ {
+ $result = $this->resolve($construction, $filter, $templateVariables);
+
+ return str_replace(['{', '}'], '', (string) $result);
+ }
+
/**
* @inheritdoc
*/
diff --git a/Filter/DirectiveProcessor/SimpleDirective.php b/Filter/DirectiveProcessor/SimpleDirective.php
index 9f4b30d0c96..b9280aec283 100644
--- a/Filter/DirectiveProcessor/SimpleDirective.php
+++ b/Filter/DirectiveProcessor/SimpleDirective.php
@@ -68,7 +68,7 @@ class SimpleDirective implements DirectiveProcessorInterface
->get($construction['directiveName']);
} catch (\InvalidArgumentException $e) {
// This directive doesn't have a SimpleProcessor
- return $construction[0];
+ return '';
}
$parameters = $this->extractParameters($construction, $filter, $templateVariables);
@@ -79,6 +79,8 @@ class SimpleDirective implements DirectiveProcessorInterface
!empty($construction['content']) ? $filter->filter($construction['content']) : null
);
+ $value = str_replace(['{', '}'], '', (string) $value);
+
$value = $this->filterApplier->applyFromRawParam(
$construction['filters'] ?? '',
$value,
diff --git a/Filter/DirectiveProcessor/VarDirective.php b/Filter/DirectiveProcessor/VarDirective.php
index 78034d70ba5..a7d6790acc7 100644
--- a/Filter/DirectiveProcessor/VarDirective.php
+++ b/Filter/DirectiveProcessor/VarDirective.php
@@ -55,10 +55,7 @@ class VarDirective implements DirectiveProcessorInterface
$result = $this->filterApplier->applyFromRawParam($construction['filters'], $result);
}
- $pattern = '/{{.*?}}/';
- do {
- $result = preg_replace($pattern, '', (string)$result);
- } while (preg_match($pattern, $result));
+ $result = str_replace(['{', '}'], '', (string) $result);
return $result;
}