Skip to content

Commit 03cce39

Browse files
Minor fixes around parse_url() checks
1 parent dd5d1a7 commit 03cce39

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

AbstractBrowser.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,11 @@ public function request(string $method, string $uri, array $parameters = [], arr
366366

367367
$server = array_merge($this->server, $server);
368368

369-
if (!empty($server['HTTP_HOST']) && null === parse_url($originalUri, \PHP_URL_HOST)) {
369+
if (!empty($server['HTTP_HOST']) && !parse_url($originalUri, \PHP_URL_HOST)) {
370370
$uri = preg_replace('{^(https?\://)'.preg_quote($this->extractHost($uri)).'}', '${1}'.$server['HTTP_HOST'], $uri);
371371
}
372372

373-
if (isset($server['HTTPS']) && null === parse_url($originalUri, \PHP_URL_SCHEME)) {
373+
if (isset($server['HTTPS']) && !parse_url($originalUri, \PHP_URL_SCHEME)) {
374374
$uri = preg_replace('{^'.parse_url($uri, \PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri);
375375
}
376376

@@ -382,7 +382,7 @@ public function request(string $method, string $uri, array $parameters = [], arr
382382
$server['HTTP_HOST'] = $this->extractHost($uri);
383383
}
384384

385-
$server['HTTPS'] = 'https' == parse_url($uri, \PHP_URL_SCHEME);
385+
$server['HTTPS'] = 'https' === parse_url($uri, \PHP_URL_SCHEME);
386386

387387
$this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content);
388388

Cookie.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public static function fromString(string $cookie, ?string $url = null)
148148
];
149149

150150
if (null !== $url) {
151-
if ((false === $urlParts = parse_url($url)) || !isset($urlParts['host'])) {
151+
if (false === ($urlParts = parse_url($url)) || !isset($urlParts['host'])) {
152152
throw new \InvalidArgumentException(sprintf('The URL "%s" is not valid.', $url));
153153
}
154154

@@ -161,7 +161,7 @@ public static function fromString(string $cookie, ?string $url = null)
161161

162162
if ('secure' === strtolower($part)) {
163163
// Ignore the secure flag if the original URI is not given or is not HTTPS
164-
if (!$url || !isset($urlParts['scheme']) || 'https' != $urlParts['scheme']) {
164+
if (null === $url || !isset($urlParts['scheme']) || 'https' != $urlParts['scheme']) {
165165
continue;
166166
}
167167

0 commit comments

Comments
 (0)