From e3a47d70f99a0dbbb427b3146ae9571cecc44296 Mon Sep 17 00:00:00 2001
From: Allison Karlitskaya <allison.karlitskaya@redhat.com>
Date: Tue, 21 Apr 2026 10:44:05 +0200
Subject: [PATCH] pkg/systemd: robustify argument quoting

If we were in Python we'd be using `shlex.quote()` here.  Unfortunately
we don't have that in JavaScript but the approach is trivial, so let's
use it here.
---
 pkg/systemd/logsJournal.jsx | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pkg/systemd/logsJournal.jsx b/pkg/systemd/logsJournal.jsx
index 99bba4a..0d1bf3b 100644
--- a/pkg/systemd/logsJournal.jsx
+++ b/pkg/systemd/logsJournal.jsx
@@ -220,7 +220,8 @@ export class JournalBox extends React.Component {
         const service_options = Object.assign({ output: "verbose" }, options);
         let cmd = journal.build_cmd(match, service_options)[0];
 
-        cmd = cmd.map(i => i.replaceAll(" ", "\\ ")).join(" ");
+        // cribbed from Python's shlex.quote()
+        cmd = cmd.map(i => `'` + i.replaceAll(`'`, `'"'"'`) + `'`).join(" ");
         cmd = "set -o pipefail; " + cmd + " | grep SYSLOG_IDENTIFIER= | sort -u";
         cockpit.spawn(["/bin/bash", "-ec", cmd], { superuser: "try", err: "message" })
                 .then(entries => {
