Strip ANSI codes from command output before sending it to the browser

Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
This commit is contained in:
Pablo Zmdl
2026-05-28 14:48:04 +02:00
parent 1b122ac01b
commit 33be747932

View File

@@ -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}";
}