From 69b7965446d3bd146b4019272a7d4a832ca9e9b5 Mon Sep 17 00:00:00 2001 From: Lirian Su Date: Fri, 22 May 2026 15:06:11 +0800 Subject: [PATCH] fix(core): preserve replace-pattern characters in bundled runtime IIFE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `injectInterceptor` used `String.prototype.replace(target, replacement)` to inject the runtime ``; } if (sanitized.includes("")) { - return sanitized.replace("", `${tag}\n`); + // Use a function replacer so `String.prototype.replace`'s substitution + // patterns (`$&`, `$$`, `$'`, `` $` ``, `$1`–`$99`) inside the inlined + // runtime IIFE are passed through verbatim. The minified runtime + // contains the literal sequence `$&` as part of legitimate JS, and + // the older `(pattern, string)` form would expand it to the matched + // ``, silently corrupting the runtime and breaking every + // timeline in the bundle with a parse-time SyntaxError. + return sanitized.replace("", () => `${tag}\n`); } const htmlOpenMatch = sanitized.match(/]*>/i); if (htmlOpenMatch?.index != null) {