From 63e45dcb20ec5d4e5f7d332e4cd97e37dda8fb88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 6 Jul 2026 20:31:48 +0200 Subject: [PATCH] fix: fix pyodide output escaping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Timothée Mazzucotelli --- .../components/content/exec/index.ts | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/assets/javascripts/components/content/exec/index.ts b/src/assets/javascripts/components/content/exec/index.ts index 8711080c..68ff262a 100644 --- a/src/assets/javascripts/components/content/exec/index.ts +++ b/src/assets/javascripts/components/content/exec/index.ts @@ -23,8 +23,6 @@ * IN THE SOFTWARE. */ -import escapeHtml from "escape-html"; - import { Observable, catchError, @@ -200,7 +198,7 @@ function getSession(name: string, pyodide: PyodideInterface): unknown { * @param string - Output */ function writeOutput(element: HTMLElement, string: string): void { - element.innerHTML = escapeHtml(string); + element.textContent = string; } /** @@ -209,18 +207,7 @@ function writeOutput(element: HTMLElement, string: string): void { * @param element - Output element */ function clearOutput(element: HTMLElement): void { - element.innerHTML = ""; -} - -/** - * Escape output like the original script - * - * @param string - Raw output - * - * @returns Escaped output - */ -function escapeOutput(string: string): string { - return new Option(string).innerHTML; + element.textContent = ""; } /** @@ -264,7 +251,7 @@ async function evaluatePython( writeOutput(output, `${lines.join("\n")}\n`); } } catch (error) { - lines.push(escapeOutput(String(error))); + lines.push(String(error)); writeOutput(output, `${lines.join("\n")}\n`); } }