|
12 | 12 | namespace Symfony\Component\HttpFoundation\Tests;
|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
| 15 | +use Symfony\Component\HttpFoundation\Exception\BadRequestException; |
15 | 16 | use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException;
|
16 | 17 | use Symfony\Component\HttpFoundation\Exception\JsonException;
|
17 | 18 | use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
|
@@ -289,9 +290,34 @@ public function testCreateWithRequestUri()
|
289 | 290 | $this->assertTrue($request->isSecure());
|
290 | 291 |
|
291 | 292 | // Fragment should not be included in the URI
|
292 |
| - $request = Request::create('http://test.com/foo#bar'); |
293 |
| - $request->server->set('REQUEST_URI', 'http://test.com/foo#bar'); |
| 293 | + $request = Request::create('http://test.com/foo#bar\\baz'); |
| 294 | + $request->server->set('REQUEST_URI', 'http://test.com/foo#bar\\baz'); |
294 | 295 | $this->assertEquals('http://test.com/foo', $request->getUri());
|
| 296 | + |
| 297 | + $request = Request::create('http://test.com/foo?bar=f\\o'); |
| 298 | + $this->assertEquals('http://test.com/foo?bar=f%5Co', $request->getUri()); |
| 299 | + $this->assertEquals('/foo', $request->getPathInfo()); |
| 300 | + $this->assertEquals('bar=f%5Co', $request->getQueryString()); |
| 301 | + } |
| 302 | + |
| 303 | + /** |
| 304 | + * @testWith ["http://foo.com\\bar"] |
| 305 | + * ["\\\\foo.com/bar"] |
| 306 | + * ["a\rb"] |
| 307 | + * ["a\nb"] |
| 308 | + * ["a\tb"] |
| 309 | + * ["\u0000foo"] |
| 310 | + * ["foo\u0000"] |
| 311 | + * [" foo"] |
| 312 | + * ["foo "] |
| 313 | + * [":"] |
| 314 | + */ |
| 315 | + public function testCreateWithBadRequestUri(string $uri) |
| 316 | + { |
| 317 | + $this->expectException(BadRequestException::class); |
| 318 | + $this->expectExceptionMessage('Invalid URI'); |
| 319 | + |
| 320 | + Request::create($uri); |
295 | 321 | }
|
296 | 322 |
|
297 | 323 | /**
|
@@ -2655,13 +2681,6 @@ public function testReservedFlags()
|
2655 | 2681 | $this->assertNotSame(0b10000000, $value, sprintf('The constant "%s" should not use the reserved value "0b10000000".', $constant));
|
2656 | 2682 | }
|
2657 | 2683 | }
|
2658 |
| - |
2659 |
| - public function testMalformedUriCreationException() |
2660 |
| - { |
2661 |
| - $this->expectException(\InvalidArgumentException::class); |
2662 |
| - $this->expectExceptionMessage('Malformed URI "/invalid-path:123".'); |
2663 |
| - Request::create('/invalid-path:123'); |
2664 |
| - } |
2665 | 2684 | }
|
2666 | 2685 |
|
2667 | 2686 | class RequestContentProxy extends Request
|
|
0 commit comments