create-prisma-php-app 3.0.1 → 3.0.2
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.
|
@@ -21,6 +21,13 @@ use ReflectionProperty;
|
|
|
21
21
|
class TemplateCompiler
|
|
22
22
|
{
|
|
23
23
|
protected const BINDING_REGEX = '/\{\{\s*((?:(?!\{\{|\}\})[\s\S])*?)\s*\}\}/uS';
|
|
24
|
+
private const LITERAL_TEXT_TAGS = [
|
|
25
|
+
'code' => true,
|
|
26
|
+
'pre' => true,
|
|
27
|
+
'samp' => true,
|
|
28
|
+
'kbd' => true,
|
|
29
|
+
'var' => true,
|
|
30
|
+
];
|
|
24
31
|
|
|
25
32
|
protected static array $classMappings = [];
|
|
26
33
|
protected static array $selfClosingTags = [
|
|
@@ -141,23 +148,22 @@ class TemplateCompiler
|
|
|
141
148
|
|
|
142
149
|
public static function convertToXml(string $templateContent): DOMDocument
|
|
143
150
|
{
|
|
144
|
-
$
|
|
145
|
-
$
|
|
151
|
+
$content = self::protectInlineScripts($templateContent);
|
|
152
|
+
$content = self::normalizeNamedEntities($content);
|
|
146
153
|
|
|
147
|
-
$
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
)
|
|
151
|
-
);
|
|
154
|
+
$content = self::escapeAmpersands($content);
|
|
155
|
+
$content = self::escapeAttributeAngles($content);
|
|
156
|
+
$content = self::escapeMustacheAngles($content);
|
|
152
157
|
|
|
153
|
-
$
|
|
154
|
-
libxml_use_internal_errors(true);
|
|
158
|
+
$xml = "<root>{$content}</root>";
|
|
155
159
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
160
|
+
$dom = new DOMDocument('1.0', 'UTF-8');
|
|
161
|
+
libxml_use_internal_errors(true);
|
|
162
|
+
if (!$dom->loadXML($xml, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET)) {
|
|
163
|
+
throw new RuntimeException(
|
|
164
|
+
'XML Parsing Failed: ' . implode('; ', self::getXmlErrors())
|
|
165
|
+
);
|
|
159
166
|
}
|
|
160
|
-
|
|
161
167
|
libxml_clear_errors();
|
|
162
168
|
libxml_use_internal_errors(false);
|
|
163
169
|
return $dom;
|
|
@@ -309,6 +315,15 @@ class TemplateCompiler
|
|
|
309
315
|
|
|
310
316
|
private static function processTextNode(DOMText $node): string
|
|
311
317
|
{
|
|
318
|
+
$parent = strtolower($node->parentNode?->nodeName ?? '');
|
|
319
|
+
if (isset(self::LITERAL_TEXT_TAGS[$parent])) {
|
|
320
|
+
return htmlspecialchars(
|
|
321
|
+
$node->textContent,
|
|
322
|
+
ENT_NOQUOTES | ENT_SUBSTITUTE,
|
|
323
|
+
'UTF-8'
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
|
|
312
327
|
return preg_replace_callback(
|
|
313
328
|
self::BINDING_REGEX,
|
|
314
329
|
fn($m) => self::processBindingExpression(trim($m[1])),
|