From f5765196e9cd5c582da04ae3bceb4ee1d62b7eae Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Tue, 21 Jan 2025 15:09:57 +0100 Subject: [PATCH] Revert "Revert "feat(server-islands): only encode ETAGO delimiter (#11513)"" (#13031) --- .changeset/fifty-socks-end.md | 5 +++++ .../src/runtime/server/render/server-islands.ts | 16 +++++++++++----- .../ssr/src/pages/empty-props.astro | 12 ++++++++++++ .../server-islands/ssr/src/pages/index.astro | 4 +++- packages/astro/test/server-islands.test.js | 11 +++++++++-- 5 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 .changeset/fifty-socks-end.md create mode 100644 packages/astro/test/fixtures/server-islands/ssr/src/pages/empty-props.astro diff --git a/.changeset/fifty-socks-end.md b/.changeset/fifty-socks-end.md new file mode 100644 index 0000000000..8b4476fbcf --- /dev/null +++ b/.changeset/fifty-socks-end.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Updates the server islands encoding logic to only escape the script end tag open delimiter and opening HTML comment syntax diff --git a/packages/astro/src/runtime/server/render/server-islands.ts b/packages/astro/src/runtime/server/render/server-islands.ts index e45b1e6d47..093254cd3e 100644 --- a/packages/astro/src/runtime/server/render/server-islands.ts +++ b/packages/astro/src/runtime/server/render/server-islands.ts @@ -15,13 +15,19 @@ export function containsServerDirective(props: Record) { return 'server:component-directive' in props; } +const SCRIPT_RE = /<\/script/giu; +const COMMENT_RE = /