From 88b4540b169910310544150508d84e6955e60114 Mon Sep 17 00:00:00 2001
From: Vincent MONNIER <80886295+vmonnier@users.noreply.github.com>
Date: Fri, 22 Aug 2025 12:22:25 +0200
Subject: [PATCH 1/3] Update me_connect.php to enhance the device response json
contant check
---
adapters/cisco_nx_rest/me_connect.php | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/adapters/cisco_nx_rest/me_connect.php b/adapters/cisco_nx_rest/me_connect.php
index a919e384..d265d875 100755
--- a/adapters/cisco_nx_rest/me_connect.php
+++ b/adapters/cisco_nx_rest/me_connect.php
@@ -165,24 +165,16 @@ protected function execute_curl_command($origin, $rest_cmd, $curl_cmd, $payload_
}
$xml;
$result = preg_replace('/xmlns="[^"]+"/', '', $result);
- if (strpos($curl_cmd, "Content-Type: application/json")) {
- $result=preg_replace('/":([0-9]+)\.([0-9]+)/', '":"$1.$2"', $result);
+ //test if result is a json content or not
+ json_decode(preg_replace('/":([0-9]+)\.([0-9]+)/', '":"$1.$2"', $result));
+ if (json_last_error() === JSON_ERROR_NONE )) {
+ $result=preg_replace('/":([0-9]+)\.([0-9]+)/', '":"$1.$2"', $result);
$array = json_decode ( $result, true );
if (isset ( $array ['sid'] )) {
$this->key = $array ['sid'];
}
-
// call array to xml conversion function
$xml = arrayToXml ( $array, '' );
- }
- elseif (strpos($curl_cmd, "content-type:application/json-rpc")) {
- $result=preg_replace('/":([0-9]+)\.([0-9]+)/', '":"$1.$2"', $result);
- $array = json_decode ( $result, true );
- if (isset ( $array ['sid'] )) {
- $this->key = $array ['sid'];
- }
- // call array to xml conversion function
- $xml = arrayToXml ($array, '');
} else {
if (empty(trim($result))) {
$result="";
From 4490e42046c81050bd3bd82d79a2baf41e8f4e02 Mon Sep 17 00:00:00 2001
From: Vincent MONNIER <80886295+vmonnier@users.noreply.github.com>
Date: Fri, 22 Aug 2025 12:25:43 +0200
Subject: [PATCH 2/3] Update me_connect.php
---
adapters/cisco_nx_rest/me_connect.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/adapters/cisco_nx_rest/me_connect.php b/adapters/cisco_nx_rest/me_connect.php
index d265d875..9dc61ab6 100755
--- a/adapters/cisco_nx_rest/me_connect.php
+++ b/adapters/cisco_nx_rest/me_connect.php
@@ -167,7 +167,7 @@ protected function execute_curl_command($origin, $rest_cmd, $curl_cmd, $payload_
$result = preg_replace('/xmlns="[^"]+"/', '', $result);
//test if result is a json content or not
json_decode(preg_replace('/":([0-9]+)\.([0-9]+)/', '":"$1.$2"', $result));
- if (json_last_error() === JSON_ERROR_NONE )) {
+ if (json_last_error() === JSON_ERROR_NONE ) {
$result=preg_replace('/":([0-9]+)\.([0-9]+)/', '":"$1.$2"', $result);
$array = json_decode ( $result, true );
if (isset ( $array ['sid'] )) {
From 6c8944a97f44506f03989fea548d8da3838abc23 Mon Sep 17 00:00:00 2001
From: Vincent MONNIER <80886295+vmonnier@users.noreply.github.com>
Date: Thu, 25 Sep 2025 13:51:06 +0200
Subject: [PATCH 3/3] Update adapters/cisco_nx_rest/me_connect.php
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---
adapters/cisco_nx_rest/me_connect.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/adapters/cisco_nx_rest/me_connect.php b/adapters/cisco_nx_rest/me_connect.php
index 9dc61ab6..f581686c 100755
--- a/adapters/cisco_nx_rest/me_connect.php
+++ b/adapters/cisco_nx_rest/me_connect.php
@@ -166,9 +166,10 @@ protected function execute_curl_command($origin, $rest_cmd, $curl_cmd, $payload_
$xml;
$result = preg_replace('/xmlns="[^"]+"/', '', $result);
//test if result is a json content or not
- json_decode(preg_replace('/":([0-9]+)\.([0-9]+)/', '":"$1.$2"', $result));
+ $json_candidate = preg_replace('/":([0-9]+)\.([0-9]+)/', '":"$1.$2"', $result);
+ json_decode($json_candidate);
if (json_last_error() === JSON_ERROR_NONE ) {
- $result=preg_replace('/":([0-9]+)\.([0-9]+)/', '":"$1.$2"', $result);
+ $result = $json_candidate;
$array = json_decode ( $result, true );
if (isset ( $array ['sid'] )) {
$this->key = $array ['sid'];