Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2f74755

Browse filesBrowse files
committed
Throw a InvalidArgumentException when calling Request::create() with a malformed URI
1 parent a1b60df commit 2f74755
Copy full SHA for 2f74755

File tree

Expand file treeCollapse file tree

4 files changed

+6
-10
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+6
-10
lines changed

‎UPGRADE-7.0.md

Copy file name to clipboardExpand all lines: UPGRADE-7.0.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ HttpFoundation
3333
* Replace `RequestMatcher` with `ChainRequestMatcher`
3434
* Replace `ExpressionRequestMatcher` with `RequestMatcher\ExpressionRequestMatcher`
3535
* Remove `Request::getContentType()`, use `Request::getContentTypeFormat()` instead
36+
* Throw an `InvalidArgumentException` when calling `Request::create()` with a malformed URI
3637

3738
Lock
3839
----

‎src/Symfony/Component/HttpFoundation/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
* Calling `ParameterBag::getInt()` and `ParameterBag::getBool()` throws an `UnexpectedValueException` on invalid value
99
* Remove classes `RequestMatcher` and `ExpressionRequestMatcher`
1010
* Remove `Request::getContentType()`, use `Request::getContentTypeFormat()` instead
11+
* Throw an `InvalidArgumentException` when calling `Request::create()` with a malformed URI
1112

1213
6.4
1314
---

‎src/Symfony/Component/HttpFoundation/Request.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Request.php
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,7 @@ public static function create(string $uri, string $method = 'GET', array $parame
345345

346346
$components = parse_url($uri);
347347
if (false === $components) {
348-
trigger_deprecation('symfony/http-foundation', '6.3', 'Calling "%s()" with an invalid URI is deprecated.', __METHOD__);
349-
$components = [];
348+
throw new \InvalidArgumentException(sprintf('Malformed URI "%s".', $uri));
350349
}
351350
if (isset($components['host'])) {
352351
$server['SERVER_NAME'] = $components['host'];

‎src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
+3-8Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\HttpFoundation\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1615
use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException;
1716
use Symfony\Component\HttpFoundation\Exception\JsonException;
1817
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
@@ -24,8 +23,6 @@
2423

2524
class RequestTest extends TestCase
2625
{
27-
use ExpectDeprecationTrait;
28-
2926
protected function tearDown(): void
3027
{
3128
Request::setTrustedProxies([], -1);
@@ -2556,12 +2553,10 @@ public function testReservedFlags()
25562553
}
25572554
}
25582555

2559-
/**
2560-
* @group legacy
2561-
*/
2562-
public function testInvalidUriCreationDeprecated()
2556+
public function testMalformedUriCreationException()
25632557
{
2564-
$this->expectDeprecation('Since symfony/http-foundation 6.3: Calling "Symfony\Component\HttpFoundation\Request::create()" with an invalid URI is deprecated.');
2558+
$this->expectException(\InvalidArgumentException::class);
2559+
$this->expectExceptionMessage('Malformed URI "/invalid-path:123".');
25652560
Request::create('/invalid-path:123');
25662561
}
25672562
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.