| @@ -33,9 +33,9 @@ | ||
| 33 | 33 | if (!$uri instanceof \YoastSEO_Vendor\Psr\Http\Message\UriInterface) { |
| 34 | 34 | $uri = new \YoastSEO_Vendor\GuzzleHttp\Psr7\Uri($uri); |
| 35 | 35 | } |
| 36 | 36 | self::warnOnMethodCasingChange($method); |
| 37 | - $this->method = \strtoupper($method); | |
| 37 | + $this->method = \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::asciiToUpper($method); | |
| 38 | 38 | $this->uri = $uri; |
| 39 | 39 | $this->setHeaders($headers); |
| 40 | 40 | $this->protocol = $version; |
| 41 | 41 | if (!isset($this->headerNames['host'])) { |
| @@ -60,9 +60,13 @@ | ||
| 60 | 60 | return $target; |
| 61 | 61 | } |
| 62 | 62 | public function withRequestTarget($requestTarget) : \YoastSEO_Vendor\Psr\Http\Message\RequestInterface |
| 63 | 63 | { |
| 64 | - if (\preg_match('#\\s#', $requestTarget)) { | |
| 64 | + $hasWhitespace = \preg_match('#\\s#', $requestTarget); | |
| 65 | + if ($hasWhitespace === \false) { | |
| 66 | + throw new \RuntimeException('Unable to validate request target: ' . \preg_last_error_msg()); | |
| 67 | + } | |
| 68 | + if ($hasWhitespace === 1) { | |
| 65 | 69 | throw new \InvalidArgumentException('Invalid request target provided; cannot contain whitespace'); |
| 66 | 70 | } |
| 67 | 71 | $new = clone $this; |
| 68 | 72 | $new->requestTarget = $requestTarget; |
| @@ -76,9 +80,9 @@ | ||
| 76 | 80 | { |
| 77 | 81 | $this->assertMethod($method); |
| 78 | 82 | self::warnOnMethodCasingChange($method); |
| 79 | 83 | $new = clone $this; |
| 80 | - $new->method = \strtoupper($method); | |
| 84 | + $new->method = \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::asciiToUpper($method); | |
| 81 | 85 | return $new; |
| 82 | 86 | } |
| 83 | 87 | public function getUri() : \YoastSEO_Vendor\Psr\Http\Message\UriInterface |
| 84 | 88 | { |
| @@ -131,9 +135,9 @@ | ||
| 131 | 135 | $this->assertNoLineSeparators($method, 'Method'); |
| 132 | 136 | } |
| 133 | 137 | private static function warnOnMethodCasingChange(string $method) : void |
| 134 | 138 | { |
| 135 | - if ($method !== \strtoupper($method)) { | |
| 139 | + if ($method !== \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::asciiToUpper($method)) { | |
| 136 | 140 | \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/psr7', '2.11', 'Passing a non-uppercase HTTP method is deprecated; guzzlehttp/psr7 3.0 preserves method casing and will no longer uppercase it. Normalize the method before constructing or modifying requests if uppercase is required.'); |
| 137 | 141 | } |
| 138 | 142 | } |
| 139 | 143 | } |