create-prisma-php-app 4.0.0-alpha.49 → 4.0.0-alpha.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -132,11 +132,23 @@ class TemplateCompiler
|
|
|
132
132
|
|
|
133
133
|
private static function escapeAmpersands(string $content): string
|
|
134
134
|
{
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
135
|
+
$parts = preg_split('/(<!\[CDATA\[[\s\S]*?\]\]>)/', $content, -1, PREG_SPLIT_DELIM_CAPTURE);
|
|
136
|
+
if ($parts === false) {
|
|
137
|
+
return $content;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
foreach ($parts as $i => $part) {
|
|
141
|
+
if (str_starts_with($part, '<![CDATA[')) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
$parts[$i] = preg_replace(
|
|
146
|
+
'/&(?![a-zA-Z][A-Za-z0-9]*;|#[0-9]+;|#x[0-9A-Fa-f]+;)/',
|
|
147
|
+
'&',
|
|
148
|
+
$part
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
return implode('', $parts);
|
|
140
152
|
}
|
|
141
153
|
|
|
142
154
|
private static function escapeAttributeAngles(string $html): string
|
|
@@ -182,24 +194,34 @@ class TemplateCompiler
|
|
|
182
194
|
|
|
183
195
|
private static function normalizeNamedEntities(string $html): string
|
|
184
196
|
{
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
197
|
+
$parts = preg_split('/(<!\[CDATA\[[\s\S]*?\]\]>)/', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
|
|
198
|
+
if ($parts === false) {
|
|
199
|
+
return $html;
|
|
200
|
+
}
|
|
189
201
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
202
|
+
foreach ($parts as $i => $part) {
|
|
203
|
+
if (str_starts_with($part, '<![CDATA[')) {
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
193
206
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
207
|
+
$parts[$i] = preg_replace_callback(
|
|
208
|
+
'/&([a-zA-Z][a-zA-Z0-9]+);/',
|
|
209
|
+
static function (array $m): string {
|
|
210
|
+
$decoded = html_entity_decode($m[0], ENT_HTML5, 'UTF-8');
|
|
211
|
+
if ($decoded === $m[0]) {
|
|
212
|
+
return $m[0];
|
|
213
|
+
}
|
|
214
|
+
if (function_exists('mb_ord')) {
|
|
215
|
+
return '&#' . mb_ord($decoded, 'UTF-8') . ';';
|
|
216
|
+
}
|
|
217
|
+
$code = unpack('N', mb_convert_encoding($decoded, 'UCS-4BE', 'UTF-8'))[1];
|
|
218
|
+
return '&#' . $code . ';';
|
|
219
|
+
},
|
|
220
|
+
$part
|
|
221
|
+
);
|
|
222
|
+
}
|
|
197
223
|
|
|
198
|
-
|
|
199
|
-
return '&#' . $code . ';';
|
|
200
|
-
},
|
|
201
|
-
$html
|
|
202
|
-
);
|
|
224
|
+
return implode('', $parts);
|
|
203
225
|
}
|
|
204
226
|
|
|
205
227
|
private static function protectInlineScripts(string $html): string
|