From 4f02616e6fba3b1baf8d45725f847841b44fc15c Mon Sep 17 00:00:00 2001
From: Jordi Boggiano <j.boggiano@seld.be>
Date: Tue, 14 Apr 2026 10:41:57 +0200
Subject: [PATCH] Merge commit from fork

Co-authored-by: Stephan Vock <stephan.vock@gmail.com>
---
 src/Composer/Util/Perforce.php            |  6 +-
 tests/Composer/Test/Util/PerforceTest.php | 82 ++++++++++++++++++-----
 2 files changed, 67 insertions(+), 21 deletions(-)

Index: SRC/src/Composer/Util/Perforce.php
===================================================================
--- SRC.orig/src/Composer/Util/Perforce.php
+++ SRC/src/Composer/Util/Perforce.php
@@ -311,11 +311,11 @@ return $password;
 public function generateP4Command(string $command, bool $useClient = true): string
 {
 $p4Command = $this->getP4Executable().' ';
-$p4Command .= '-u ' . $this->getUser() . ' ';
+$p4Command .= '-u ' . ProcessExecutor::escape($this->getUser()) . ' ';
 if ($useClient) {
-$p4Command .= '-c ' . $this->getClient() . ' ';
+$p4Command .= '-c ' . ProcessExecutor::escape($this->getClient()) . ' ';
 }
-$p4Command .= '-p ' . $this->getPort() . ' ' . $command;
+$p4Command .= '-p ' . ProcessExecutor::escape($this->getPort()) . ' ' . $command;
 
 return $p4Command;
 }
