From d12a5b5acdd9af99edfe0718bb341e841aa5dc20 Mon Sep 17 00:00:00 2001 From: Pi <90981829+ItsPi3141@users.noreply.github.com> Date: Fri, 17 Mar 2023 22:43:14 -0700 Subject: [PATCH] Fix character errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List of changes: - Allow quotes (") and line breaks (\n). They no longer break the shell command. - Remove a bug where a line break followed by "" is randomly added to the generated text --- bin/web/views/index.ejs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/web/views/index.ejs b/bin/web/views/index.ejs index 425b64d..a0e956a 100644 --- a/bin/web/views/index.ejs +++ b/bin/web/views/index.ejs @@ -179,7 +179,7 @@ form.addEventListener('submit', (e) => { e.preventDefault(); e.stopPropagation() if (input.textContent) { - config.prompt = input.textContent + config.prompt = input.textContent.replaceAll("\n", "\\n").replaceAll('"', '\\\\\\""'); config.id = "TS-" + Date.now() + "-" + Math.floor(Math.random() * 100000) socket.emit('request', config) config.id = null @@ -232,6 +232,9 @@ socket.on('result', async ({ request, response }) => { let existing = document.querySelector(`[data-id='${id}']`) if (existing) { existing.textContent = existing.textContent + response + existing.textContent = existing.textContent.replaceAll(/\r?\n\x1B\[\d+;\d+H./g, ""); + existing.textContent = existing.textContent.replaceAll("\\n", "\n"); + existing.textContent = existing.textContent.replaceAll('\\"', '"'); } else { say(response, id) }