From b790b80dbb4f8a2cbf4a2af568e30782e01a303e Mon Sep 17 00:00:00 2001 From: w-e-w <40751091+w-e-w@users.noreply.github.com> Date: Tue, 27 Aug 2024 15:09:19 +0900 Subject: [PATCH 1/2] json.dumps for quote_js --- modules/ui_extra_networks.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/ui_extra_networks.py b/modules/ui_extra_networks.py index 6e9ec164552..1f19bd36d12 100644 --- a/modules/ui_extra_networks.py +++ b/modules/ui_extra_networks.py @@ -177,10 +177,8 @@ def add_pages_to_demo(app): app.add_api_route("/sd_extra_networks/get-single-card", get_single_card, methods=["GET"]) -def quote_js(s): - s = s.replace('\\', '\\\\') - s = s.replace('"', '\\"') - return f'"{s}"' +def quote_js(s: str): + return json.dumps(s, ensure_ascii=False) class ExtraNetworksPage: From e0bce107c8b4396ee34ec05e7af9f07ee3de5319 Mon Sep 17 00:00:00 2001 From: w-e-w <40751091+w-e-w@users.noreply.github.com> Date: Tue, 27 Aug 2024 15:13:30 +0900 Subject: [PATCH 2/2] allow newline in activation text --- javascript/extraNetworks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript/extraNetworks.js b/javascript/extraNetworks.js index c5cced97399..8e8adad0bae 100644 --- a/javascript/extraNetworks.js +++ b/javascript/extraNetworks.js @@ -201,7 +201,7 @@ function setupExtraNetworks() { setupExtraNetworksForTab('img2img'); } -var re_extranet = /<([^:^>]+:[^:]+):[\d.]+>(.*)/; +var re_extranet = /<([^:^>]+:[^:]+):[\d.]+>(.*)/s; var re_extranet_g = /<([^:^>]+:[^:]+):[\d.]+>/g; var re_extranet_neg = /\(([^:^>]+:[\d.]+)\)/;