Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/updraftp.../vendor/guzzleht.../psr7/src
File: Header.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace GuzzleHttp\Psr7;
[2] Fix | Delete
[3] Fix | Delete
final class Header
[4] Fix | Delete
{
[5] Fix | Delete
/**
[6] Fix | Delete
* Parse an array of header values containing ";" separated data into an
[7] Fix | Delete
* array of associative arrays representing the header key value pair data
[8] Fix | Delete
* of the header. When a parameter does not contain a value, but just
[9] Fix | Delete
* contains a key, this function will inject a key with a '' string value.
[10] Fix | Delete
*
[11] Fix | Delete
* @param string|array $header Header to parse into components.
[12] Fix | Delete
*
[13] Fix | Delete
* @return array Returns the parsed header values.
[14] Fix | Delete
*/
[15] Fix | Delete
public static function parse($header)
[16] Fix | Delete
{
[17] Fix | Delete
static $trimmed = "\"' \n\t\r";
[18] Fix | Delete
$params = $matches = [];
[19] Fix | Delete
[20] Fix | Delete
foreach (self::normalize($header) as $val) {
[21] Fix | Delete
$part = [];
[22] Fix | Delete
foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) {
[23] Fix | Delete
if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
[24] Fix | Delete
$m = $matches[0];
[25] Fix | Delete
if (isset($m[1])) {
[26] Fix | Delete
$part[trim($m[0], $trimmed)] = trim($m[1], $trimmed);
[27] Fix | Delete
} else {
[28] Fix | Delete
$part[] = trim($m[0], $trimmed);
[29] Fix | Delete
}
[30] Fix | Delete
}
[31] Fix | Delete
}
[32] Fix | Delete
if ($part) {
[33] Fix | Delete
$params[] = $part;
[34] Fix | Delete
}
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
return $params;
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
/**
[41] Fix | Delete
* Converts an array of header values that may contain comma separated
[42] Fix | Delete
* headers into an array of headers with no comma separated values.
[43] Fix | Delete
*
[44] Fix | Delete
* @param string|array $header Header to normalize.
[45] Fix | Delete
*
[46] Fix | Delete
* @return array Returns the normalized header field values.
[47] Fix | Delete
*/
[48] Fix | Delete
public static function normalize($header)
[49] Fix | Delete
{
[50] Fix | Delete
if (!is_array($header)) {
[51] Fix | Delete
return array_map('trim', explode(',', $header));
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
$result = [];
[55] Fix | Delete
foreach ($header as $value) {
[56] Fix | Delete
foreach ((array) $value as $v) {
[57] Fix | Delete
if (strpos($v, ',') === false) {
[58] Fix | Delete
$result[] = $v;
[59] Fix | Delete
continue;
[60] Fix | Delete
}
[61] Fix | Delete
foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) {
[62] Fix | Delete
$result[] = trim($vv);
[63] Fix | Delete
}
[64] Fix | Delete
}
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
return $result;
[68] Fix | Delete
}
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function