From 1e941fd885c799f2d38f4084a6f4cb9438813c8f Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Mon, 19 Feb 2024 12:07:47 +0100
Subject: [PATCH] fix(helmv3): use shlex

---
 .../manager/helmv3/__snapshots__/artifacts.spec.ts.snap       | 2 +-
 lib/modules/manager/helmv3/artifacts.spec.ts                  | 2 +-
 lib/modules/manager/helmv3/artifacts.ts                       | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap b/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap
index 61454159f8..ea3ede2331 100644
--- a/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap
+++ b/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap
@@ -496,7 +496,7 @@ exports[`modules/manager/helmv3/artifacts returns updated Chart.lock with docker
 exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases 1`] = `
 [
   {
-    "cmd": "helm repo add stable the_stable_url --force-update",
+    "cmd": "helm repo add stable 'the stable_url' --force-update",
     "options": {
       "cwd": "/tmp/github/some/repo",
       "encoding": "utf-8",
diff --git a/lib/modules/manager/helmv3/artifacts.spec.ts b/lib/modules/manager/helmv3/artifacts.spec.ts
index 2a551f1c4b..3ce9ba21de 100644
--- a/lib/modules/manager/helmv3/artifacts.spec.ts
+++ b/lib/modules/manager/helmv3/artifacts.spec.ts
@@ -593,7 +593,7 @@ describe('modules/manager/helmv3/artifacts', () => {
         config: {
           ...config,
           updateType: 'lockFileMaintenance',
-          registryAliases: { stable: 'the_stable_url', repo1: 'the_repo1_url' },
+          registryAliases: { stable: 'the stable_url', repo1: 'the_repo1_url' },
         },
       }),
     ).toMatchObject([
diff --git a/lib/modules/manager/helmv3/artifacts.ts b/lib/modules/manager/helmv3/artifacts.ts
index abc8e6887b..df8fe8ba08 100644
--- a/lib/modules/manager/helmv3/artifacts.ts
+++ b/lib/modules/manager/helmv3/artifacts.ts
@@ -70,14 +70,14 @@ async function helmCommands(
   // add helm repos if an alias or credentials for the url are defined
   classicRepositories.forEach((value) => {
     const { username, password } = value.hostRule;
-    const parameters = [`${value.repository}`, `--force-update`];
+    const parameters = [`${quote(value.repository)}`, `--force-update`];
     const isPrivateRepo = username && password;
     if (isPrivateRepo) {
       parameters.push(`--username ${quote(username)}`);
       parameters.push(`--password ${quote(password)}`);
     }
 
-    cmd.push(`helm repo add ${value.name} ${parameters.join(' ')}`);
+    cmd.push(`helm repo add ${quote(value.name)} ${parameters.join(' ')}`);
   });
 
   cmd.push(`helm dependency update ${quote(getParentDir(manifestPath))}`);
-- 
GitLab