PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
← All changes | vendor_prefixed/guzzlehttp/psr7/src/Header.php +37 -3 27.7 → trunk View file →
@@ -19,9 +19,9 @@
19 19 $params = $matches = [];
20 20 foreach ((array) $header as $value) {
21 21 foreach (self::splitList($value) as $val) {
22 22 $part = [];
23 - foreach (\preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) ?: [] as $kvp) {
23 + foreach (self::splitParameters($val) as $kvp) {
24 24 if (\preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
25 25 $m = $matches[0];
26 26 if (isset($m[1])) {
27 27 $part[\trim($m[0], $trimmed)] = \trim($m[1], $trimmed);
@@ -37,8 +37,41 @@
37 37 }
38 38 return $params;
39 39 }
40 40 /**
41 + * Split a header value into semicolon-separated parameters.
42 + *
43 + * @return string[]
44 + */
45 + private static function splitParameters(string $value) : array
46 + {
47 + $values = [];
48 + $start = 0;
49 + $isQuoted = \false;
50 + $isEscaped = \false;
51 + for ($i = 0, $max = \strlen($value); $i < $max; ++$i) {
52 + $char = $value[$i];
53 + if ($isEscaped) {
54 + $isEscaped = \false;
55 + continue;
56 + }
57 + if ($isQuoted && $char === '\\') {
58 + $isEscaped = \true;
59 + continue;
60 + }
61 + if ($char === '"') {
62 + $isQuoted = !$isQuoted;
63 + continue;
64 + }
65 + if (!$isQuoted && $char === ';') {
66 + $values[] = \substr($value, $start, $i - $start);
67 + $start = $i + 1;
68 + }
69 + }
70 + $values[] = \substr($value, $start);
71 + return $values;
72 + }
73 + /**
41 74 * Converts an array of header values that may contain comma separated
42 75 * headers into an array of headers with no comma separated values.
43 76 *
44 77 * @param string|array $header Header to normalize.
@@ -46,8 +79,9 @@
46 79 * @deprecated Use self::splitList() instead.
47 80 */
48 81 public static function normalize($header) : array
49 82 {
83 + \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/psr7', '2.3', 'Header::normalize() is deprecated and will be removed in guzzlehttp/psr7 3.0. Use Header::splitList() instead.');
50 84 $result = [];
51 85 foreach ((array) $header as $value) {
52 86 foreach (self::splitList($value) as $parsed) {
53 87 $result[] = $parsed;
@@ -87,9 +121,9 @@
87 121 $isEscaped = \false;
88 122 continue;
89 123 }
90 124 if (!$isQuoted && $value[$i] === ',') {
91 - $v = \trim($v);
125 + $v = \trim($v, " \n\r\t\x00\v");
92 126 if ($v !== '') {
93 127 $result[] = $v;
94 128 }
95 129 $v = '';
@@ -106,9 +140,9 @@
106 140 continue;
107 141 }
108 142 $v .= $value[$i];
109 143 }
110 - $v = \trim($v);
144 + $v = \trim($v, " \n\r\t\x00\v");
111 145 if ($v !== '') {
112 146 $result[] = $v;
113 147 }
114 148 }