From 74dd5affdee41b814b8c4aca6456b9b85c186dd9 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Thu, 5 Dec 2019 14:43:28 +0100
Subject: [PATCH] FIX #12432 TIME 0:10 improve control in execsoap

---
 src/core/models/CurlModel.php | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/core/models/CurlModel.php b/src/core/models/CurlModel.php
index e205d0fb579..40924277d20 100644
--- a/src/core/models/CurlModel.php
+++ b/src/core/models/CurlModel.php
@@ -145,7 +145,7 @@ class CurlModel
 
         $cookies = [];
         if (!empty($aArgs['options'][CURLOPT_HEADER])) {
-            preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $rawResponse, $matches);
+            preg_match_all('/Set-Cookie:\s*([;]*)/mi', $rawResponse, $matches);
             foreach ($matches[1] as $item) {
                 $cookie = explode("=", $item);
                 $cookies = array_merge($cookies, [$cookie[0] => $cookie[1]]);
@@ -154,7 +154,14 @@ class CurlModel
         } elseif (!empty($aArgs['delete_header'])) { // Delete header for iparapheur
             $body = explode(PHP_EOL . PHP_EOL, $rawResponse)[1]; // put the header ahead
             if (empty($body)) {
-                $body = explode(PHP_EOL, $rawResponse)[5];
+                $body = explode(PHP_EOL, $rawResponse);
+                // we remove the 4 starting item of the array (header)
+                for ($i=0; $i < 5; $i++) {
+                    array_shift($body);
+                }
+                // and the last item (footer)
+                array_pop($body);
+                $body = join('', $body);
             }
             $pattern = '/--uuid:[0-9a-f-]+--/';                  // And also the footer
             $rawResponse = preg_replace($pattern, '', $body);
-- 
GitLab