diff --git a/snappymail/v/0.0.0/app/libraries/snappymail/http/request/curl.php b/snappymail/v/0.0.0/app/libraries/snappymail/http/request/curl.php index f25fef1c0..31559d112 100644 --- a/snappymail/v/0.0.0/app/libraries/snappymail/http/request/curl.php +++ b/snappymail/v/0.0.0/app/libraries/snappymail/http/request/curl.php @@ -47,7 +47,14 @@ class CURL extends \SnappyMail\HTTP\Request \curl_setopt($c, CURLOPT_CAINFO, $this->ca_bundle); } if ($extra_headers) { - \curl_setopt($c, CURLOPT_HTTPHEADER, $extra_headers); + // CURLOPT_HTTPHEADER expects a flat list of "Name: value" strings. + // Callers may pass an associative array, in which case curl sends + // the bare values as malformed header lines and drops them. + $aHeaderLines = array(); + foreach ($extra_headers as $mKey => $sValue) { + $aHeaderLines[] = \is_int($mKey) ? $sValue : "{$mKey}: {$sValue}"; + } + \curl_setopt($c, CURLOPT_HTTPHEADER, $aHeaderLines); } if ($this->auth['user'] && $this->auth['type']) { if ($this->auth['type'] & self::AUTH_BEARER ) { diff --git a/snappymail/v/0.0.0/app/libraries/snappymail/http/request/socket.php b/snappymail/v/0.0.0/app/libraries/snappymail/http/request/socket.php index 8b6ffc975..522bcd65a 100644 --- a/snappymail/v/0.0.0/app/libraries/snappymail/http/request/socket.php +++ b/snappymail/v/0.0.0/app/libraries/snappymail/http/request/socket.php @@ -43,7 +43,12 @@ class Socket extends \SnappyMail\HTTP\Request $extra_headers['Authorization'] = static::$Authorization[$host]; } if ($extra_headers) { - $headers = \array_merge($headers, $extra_headers); + // $headers is a flat list of "Name: value" strings, so an + // associative $extra_headers would lose its keys in the implode() + // below and emit bare values as malformed header lines. + foreach ($extra_headers as $mKey => $sValue) { + $headers[] = \is_int($mKey) ? $sValue : "{$mKey}: {$sValue}"; + } } $headers = \implode("\r\n", $headers); if (!\is_null($body)) {