From 477c0123ed262844952056cb5574d9e47ead9bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=A4=E6=9C=88?= <17949154+yazhouio@users.noreply.github.com> Date: Tue, 24 Dec 2024 11:21:09 +0800 Subject: [PATCH] fix: Update global variable handling in views to use decodeURIComponent Signed-off-by: ya zhou --- server/controllers/view.js | 62 ++++++++++++++++++++----------------- server/views/consolev3.html | 2 +- server/views/index.html | 2 +- server/views/terminal.html | 2 +- 4 files changed, 37 insertions(+), 31 deletions(-) diff --git a/server/controllers/view.js b/server/controllers/view.js index 5c4bb84e29d..2ac8b8e3973 100644 --- a/server/controllers/view.js +++ b/server/controllers/view.js @@ -55,15 +55,17 @@ const renderIndex = async (ctx, params) => { extStyles, hostname: ctx.hostname, importMap: JSON.stringify(importMap), - globals: JSON.stringify({ - config: clientConfig, - manifest, - localeManifest, - theme, - defaultTheme, - useDefaultTheme, - ...params, - }), + globals: encodeURIComponent( + JSON.stringify({ + config: clientConfig, + manifest, + localeManifest, + theme, + defaultTheme, + useDefaultTheme, + ...params, + }), + ) }); }; @@ -82,16 +84,18 @@ const renderV3Index = async (ctx, params) => { isDev: global.MODE_DEV, title: clientConfig.title, hostname: ctx.hostname, - globals: JSON.stringify({ - config: clientConfig, - localeManifest, + globals: encodeURIComponent( + JSON.stringify({ + config: clientConfig, + localeManifest, - theme, - defaultTheme, - useDefaultTheme, + theme, + defaultTheme, + useDefaultTheme, - ...params, - }), + ...params, + }), + ) }); }; @@ -164,17 +168,19 @@ const renderTerminal = async ctx => { favicon, hostname: ctx.hostname, importMap: JSON.stringify(importMap), - globals: JSON.stringify({ - config: clientConfig, - manifest, - localeManifest, - user, - ksConfig, - runtime, - theme, - defaultTheme, - useDefaultTheme, - }), + globals: encodeURIComponent( + JSON.stringify({ + config: clientConfig, + manifest, + localeManifest, + user, + ksConfig, + runtime, + theme, + defaultTheme, + useDefaultTheme, + }), + ) }); } catch (err) { await renderViewErr(ctx, err); diff --git a/server/views/consolev3.html b/server/views/consolev3.html index 3c80ecc6f9a..c272aa5f87a 100644 --- a/server/views/consolev3.html +++ b/server/views/consolev3.html @@ -18,7 +18,7 @@
<% if (manifest && manifest.js && manifest.js.length > 0) { %> <% manifest.js.forEach(function(item){ %> diff --git a/server/views/index.html b/server/views/index.html index 29a255ef6d7..b7bc0d1ac85 100644 --- a/server/views/index.html +++ b/server/views/index.html @@ -26,7 +26,7 @@ { "imports": <%- importMap %> } <% if (isDev) { %> <%- include('./components/dev_scripts.html') %> <% } else { %> <%- include('./components/prod_scripts.html') %> <% } %> diff --git a/server/views/terminal.html b/server/views/terminal.html index 3e2c0bd2e94..ed944eb14ab 100644 --- a/server/views/terminal.html +++ b/server/views/terminal.html @@ -23,7 +23,7 @@ { "imports": <%- importMap %> } <% if (isDev) { %>