Skip to content

Commit 49be6b8

Browse files
Merge branch '5.4' into 6.4
* 5.4: Work around parse_url() bug (bis) fix PHP 7.2 compatibility silence PHP warnings issued by Redis::connect() Bump Symfony version to 5.4.48 Update VERSION for 5.4.47 Update CHANGELOG for 5.4.47 [Routing] Fix: lost priority when defining hosts in configuration fix dumping tests to skip with data providers
2 parents 9b3165e + 3280c9d commit 49be6b8

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

Request.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,7 @@ public static function create(string $uri, string $method = 'GET', array $parame
351351
$server['PATH_INFO'] = '';
352352
$server['REQUEST_METHOD'] = strtoupper($method);
353353

354-
if (false === ($components = parse_url($uri)) && '/' === ($uri[0] ?? '')) {
355-
trigger_deprecation('symfony/http-foundation', '6.3', 'Calling "%s()" with an invalid URI is deprecated.', __METHOD__);
356-
$components = parse_url($uri.'#');
357-
unset($components['fragment']);
358-
}
359-
360-
if (false === $components) {
354+
if (false === $components = parse_url(\strlen($uri) !== strcspn($uri, '?#') ? $uri : $uri.'#')) {
361355
throw new BadRequestException('Invalid URI.');
362356
}
363357

@@ -380,9 +374,11 @@ public static function create(string $uri, string $method = 'GET', array $parame
380374
if ('https' === $components['scheme']) {
381375
$server['HTTPS'] = 'on';
382376
$server['SERVER_PORT'] = 443;
383-
} else {
377+
} elseif ('http' === $components['scheme']) {
384378
unset($server['HTTPS']);
385379
$server['SERVER_PORT'] = 80;
380+
} else {
381+
throw new BadRequestException('Invalid URI: http(s) scheme expected.');
386382
}
387383
}
388384

Tests/RequestTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ public function testCreateWithRequestUri()
326326
* ["foo\u0000"]
327327
* [" foo"]
328328
* ["foo "]
329-
* [":"]
329+
* ["//"]
330+
* ["foo:bar"]
330331
*/
331332
public function testCreateWithBadRequestUri(string $uri)
332333
{

0 commit comments

Comments
 (0)