create-prisma-php-app 1.27.0 → 1.27.1
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.
|
@@ -54,7 +54,22 @@ class TemplateCompiler
|
|
|
54
54
|
public static function convertToXml(string $templateContent): DOMDocument
|
|
55
55
|
{
|
|
56
56
|
// Escape `&` characters that are not part of valid XML entities
|
|
57
|
-
$templateContent =
|
|
57
|
+
$templateContent = preg_replace_callback(
|
|
58
|
+
'/&(.*?)/',
|
|
59
|
+
function ($matches) {
|
|
60
|
+
$str = $matches[0];
|
|
61
|
+
|
|
62
|
+
// If it already looks like a valid entity, leave it alone.
|
|
63
|
+
// This check can be as simple or as robust as you need.
|
|
64
|
+
if (preg_match('/^&(?:[a-zA-Z]+|#[0-9]+|#x[0-9A-Fa-f]+);$/', $str)) {
|
|
65
|
+
return $str;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Otherwise, escape it.
|
|
69
|
+
return '&' . substr($str, 1);
|
|
70
|
+
},
|
|
71
|
+
$templateContent
|
|
72
|
+
);
|
|
58
73
|
|
|
59
74
|
$dom = new DOMDocument();
|
|
60
75
|
libxml_use_internal_errors(true);
|