|
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;
|
@@ -290,9 +291,34 @@ public function testCreateWithRequestUri()
|
290 | 291 | $this->assertTrue($request->isSecure());
|
291 | 292 |
|
292 | 293 | // Fragment should not be included in the URI
|
293 |
| - $request = Request::create('http://test.com/foo#bar'); |
294 |
| - $request->server->set('REQUEST_URI', 'http://test.com/foo#bar'); |
| 294 | + $request = Request::create('http://test.com/foo#bar\\baz'); |
| 295 | + $request->server->set('REQUEST_URI', 'http://test.com/foo#bar\\baz'); |
295 | 296 | $this->assertEquals('http://test.com/foo', $request->getUri());
|
| 297 | + |
| 298 | + $request = Request::create('http://test.com/foo?bar=f\\o'); |
| 299 | + $this->assertEquals('http://test.com/foo?bar=f%5Co', $request->getUri()); |
| 300 | + $this->assertEquals('/foo', $request->getPathInfo()); |
| 301 | + $this->assertEquals('bar=f%5Co', $request->getQueryString()); |
| 302 | + } |
| 303 | + |
| 304 | + /** |
| 305 | + * @testWith ["http://foo.com\\bar"] |
| 306 | + * ["\\\\foo.com/bar"] |
| 307 | + * ["a\rb"] |
| 308 | + * ["a\nb"] |
| 309 | + * ["a\tb"] |
| 310 | + * ["\u0000foo"] |
| 311 | + * ["foo\u0000"] |
| 312 | + * [" foo"] |
| 313 | + * ["foo "] |
| 314 | + * [":"] |
| 315 | + */ |
| 316 | + public function testCreateWithBadRequestUri(string $uri) |
| 317 | + { |
| 318 | + $this->expectException(BadRequestException::class); |
| 319 | + $this->expectExceptionMessage('Invalid URI'); |
| 320 | + |
| 321 | + Request::create($uri); |
296 | 322 | }
|
297 | 323 |
|
298 | 324 | /**
|
@@ -2666,13 +2692,6 @@ public function testReservedFlags()
|
2666 | 2692 | $this->assertNotSame(0b10000000, $value, \sprintf('The constant "%s" should not use the reserved value "0b10000000".', $constant));
|
2667 | 2693 | }
|
2668 | 2694 | }
|
2669 |
| - |
2670 |
| - public function testMalformedUriCreationException() |
2671 |
| - { |
2672 |
| - $this->expectException(\InvalidArgumentException::class); |
2673 |
| - $this->expectExceptionMessage('Malformed URI "/invalid-path:123".'); |
2674 |
| - Request::create('/invalid-path:123'); |
2675 |
| - } |
2676 | 2695 | }
|
2677 | 2696 |
|
2678 | 2697 | class RequestContentProxy extends Request
|
|
0 commit comments