From 040a4d646f45e297c9f84777bea21c04ff39d3aa Mon Sep 17 00:00:00 2001 From: sorcier Date: Fri, 6 Nov 2026 02:05:33 +0100 Subject: [PATCH] fix(api): fix endpoint quoting in pjsip send notify command --- public/api.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/api.php b/public/api.php index 4e64a02..2b0848e 100644 --- a/public/api.php +++ b/public/api.php @@ -495,9 +495,14 @@ try { throw new InvalidArgumentException("Poste {$extension} introuvable."); } + $cleanExt = preg_replace('/[^a-zA-Z0-9_\-]/', '', $extension); + try { $ami = AmiClient::fromDatabase($db); - $cmdOutput = $ami->runCommand("pjsip send notify reboot endpoint " . escapeshellarg($extension)); + $cmdOutput = $ami->runCommand("pjsip send notify reboot endpoint {$cleanExt}"); + if (stripos($cmdOutput, 'Unable to') !== false) { + throw new RuntimeException("Échec Asterisk : " . trim($cmdOutput)); + } echo json_encode([ 'success' => true, 'message' => "Ordre de redémarrage envoyé au poste {$extension} ({$extRow['name']}).",