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
- return preg_replace(
136
- '/&(?![a-zA-Z][A-Za-z0-9]*;|#[0-9]+;|#x[0-9A-Fa-f]+;)/',
137
- '&',
138
- $content
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
+ '&amp;',
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
- return preg_replace_callback(
186
- '/&([a-zA-Z][a-zA-Z0-9]+);/',
187
- static function (array $m): string {
188
- $decoded = html_entity_decode($m[0], ENT_HTML5, 'UTF-8');
197
+ $parts = preg_split('/(<!\[CDATA\[[\s\S]*?\]\]>)/', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
198
+ if ($parts === false) {
199
+ return $html;
200
+ }
189
201
 
190
- if ($decoded === $m[0]) {
191
- return $m[0];
192
- }
202
+ foreach ($parts as $i => $part) {
203
+ if (str_starts_with($part, '<![CDATA[')) {
204
+ continue;
205
+ }
193
206
 
194
- if (function_exists('mb_ord')) {
195
- return '&#' . mb_ord($decoded, 'UTF-8') . ';';
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
- $code = unpack('N', mb_convert_encoding($decoded, 'UCS-4BE', 'UTF-8'))[1];
199
- return '&#' . $code . ';';
200
- },
201
- $html
202
- );
224
+ return implode('', $parts);
203
225
  }
204
226
 
205
227
  private static function protectInlineScripts(string $html): string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "4.0.0-alpha.49",
3
+ "version": "4.0.0-alpha.50",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",