From 33be7479327609700f135bccd1615178d192289e Mon Sep 17 00:00:00 2001 From: Pablo Zmdl Date: Thu, 28 May 2026 14:48:04 +0200 Subject: [PATCH] Strip ANSI codes from command output before sending it to the browser Signed-off-by: Pablo Zmdl --- php/src/Controller/DockerController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/php/src/Controller/DockerController.php b/php/src/Controller/DockerController.php index bfe38f1c..9b15df67 100644 --- a/php/src/Controller/DockerController.php +++ b/php/src/Controller/DockerController.php @@ -443,6 +443,8 @@ readonly class DockerController { // if it'll actually pull an image), but which should not need to know anything about the // wanted markup or formatting. $addToStreamingResponseBody = function (string $message, ?Container $container = null) use ($nonbufResp) : void { + // Strip ANSI codes. + $message = preg_replace('/\e[[][A-Za-z0-9];?[0-9]*m?/', '', $message); if ($container) { $message = "{$container->displayName}: {$message}"; }