create-prisma-php-app 3.0.0-rc.5 → 3.0.0-rc.6

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.
@@ -153,6 +153,7 @@ class TemplateCompiler
153
153
  public static function convertToXml(string $templateContent): DOMDocument
154
154
  {
155
155
  $templateContent = self::protectInlineScripts($templateContent);
156
+ $templateContent = self::normalizeNamedEntities($templateContent);
156
157
 
157
158
  $templateContent = self::escapeMustacheAngles(
158
159
  self::escapeAttributeAngles(
@@ -173,6 +174,28 @@ class TemplateCompiler
173
174
  return $dom;
174
175
  }
175
176
 
177
+ private static function normalizeNamedEntities(string $html): string
178
+ {
179
+ return preg_replace_callback(
180
+ '/&([a-zA-Z][a-zA-Z0-9]+);/',
181
+ static function (array $m): string {
182
+ $decoded = html_entity_decode($m[0], ENT_HTML5, 'UTF-8');
183
+
184
+ if ($decoded === $m[0]) {
185
+ return $m[0];
186
+ }
187
+
188
+ if (function_exists('mb_ord')) {
189
+ return '&#' . mb_ord($decoded, 'UTF-8') . ';';
190
+ }
191
+
192
+ $code = unpack('N', mb_convert_encoding($decoded, 'UCS-4BE', 'UTF-8'))[1];
193
+ return '&#' . $code . ';';
194
+ },
195
+ $html
196
+ );
197
+ }
198
+
176
199
  private static function protectInlineScripts(string $html): string
177
200
  {
178
201
  return preg_replace_callback(
@@ -248,7 +271,11 @@ class TemplateCompiler
248
271
  $pushed = false;
249
272
  $tag = strtolower($node->nodeName);
250
273
 
251
- if ($tag === 'script' && !$node->hasAttribute('src')) {
274
+ if (
275
+ $tag === 'script' &&
276
+ !$node->hasAttribute('src') &&
277
+ !$node->hasAttribute('type')
278
+ ) {
252
279
  $node->setAttribute('type', 'text/php');
253
280
  }
254
281
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "3.0.0-rc.5",
3
+ "version": "3.0.0-rc.6",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",