From c02b4befede3d5136a80d829b8e998bb4f4a04c3 Mon Sep 17 00:00:00 2001 From: nicoschoenteich Date: Fri, 7 Feb 2025 12:51:38 +0100 Subject: [PATCH] fix(ui5-task-zipper): recreate escaped single quotes in Component-preload.js --- packages/ui5-task-zipper/lib/zipper.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/ui5-task-zipper/lib/zipper.js b/packages/ui5-task-zipper/lib/zipper.js index a9852871..cf62ae4b 100644 --- a/packages/ui5-task-zipper/lib/zipper.js +++ b/packages/ui5-task-zipper/lib/zipper.js @@ -124,9 +124,10 @@ module.exports = async function ({ log, workspace, dependencies, options, taskUt const manifestStart = oldPreload.indexOf("manifest.json\":'{"); const manifestEnd = oldPreload.indexOf("}'", manifestStart); const oldManifest = oldPreload.substring(manifestStart + 16, manifestEnd + 1); - const oldManifestEscaped = oldManifest.replace(/\\'/g, '\\"'); - const newManifest = absoluteToRelativePaths(JSON.parse(oldManifestEscaped)); - const newPreload = oldPreload.replace(oldManifest, JSON.stringify(newManifest)); + const oldManifestNoEscapedSingleQuotes = oldManifest.replace(/\\'/g, "REPLACE_WITH_ESCAPED_SINGLE_QUOTE"); + const newManifest = absoluteToRelativePaths(JSON.parse(oldManifestNoEscapedSingleQuotes)); + const newManifestEscapedSingleQuotes = JSON.stringify(newManifest).replace(/REPLACE_WITH_ESCAPED_SINGLE_QUOTE/g, "\\'"); + const newPreload = oldPreload.replace(oldManifest, newManifestEscapedSingleQuotes); zip.addBuffer(Buffer.from(newPreload, "utf-8"), "Component-preload.js"); } else { zip.addBuffer(buffer, resourcePath); // Replace first forward slash at the start of the path