8000 Merge branch '3.4' into 4.2 · symfony/symfony@31f51ca · GitHub
[go: up one dir, main page]

Skip 8000 to content

Commit 31f51ca

Browse files
Merge branch '3.4' into 4.2
* 3.4: [HttpFoundation] Do not set X-Accel-Redirect for paths outside of X-Accel-Mapping Use AsserEquals for floating-point values
2 parents 2d72ec1 + 326a74c commit 31f51ca

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,17 @@ public function prepare(Request $request)
223223
list($pathPrefix, $location) = $part;
224224
if (substr($path, 0, \strlen($pathPrefix)) === $pathPrefix) {
225225
$path = $location.substr($path, \strlen($pathPrefix));
226+
// Only set X-Accel-Redirect header if a valid URI can be produced
227+
// as nginx does not serve arbitrary file paths.
228+
$this->headers->set($type, $path);
229+
$this->maxlen = 0;
226230
break;
227231
}
228232
}
233+
} else {
234+
$this->headers->set($type, $path);
235+
$this->maxlen = 0;
229236
}
230-
$this->headers->set($type, $path);
231-
$this->maxlen = 0;
232237
} elseif ($request->headers->has('Range')) {
233238
// Process the range headers.
234239
if (!$request->headers->has('If-Range') || $this->hasValidIfRangeHeader($request->headers->get('If-Range'))) {

src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ public function getSampleXAccelMappings()
339339
['/var/www/var/www/files/foo.txt', '/var/www/=/files/', '/files/var/www/files/foo.txt'],
340340
['/home/Foo/bar.txt', '/var/www/=/files/,/home/Foo/=/baz/', '/baz/bar.txt'],
341341
['/home/Foo/bar.txt', '"/var/www/"="/files/", "/home/Foo/"="/baz/"', '/baz/bar.txt'],
342+
['/tmp/bar.txt', '"/var/www/"="/files/", "/home/Foo/"="/baz/"', null],
342343
];
343344
}
344345

src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public function testConstructorWithSimpleTypes()
4343
$this->assertSame('0', $response->getContent());
4444

4545
$response = new JsonResponse(0.1);
46-
$this->assertSame('0.1', $response->getContent());
46+
$this->assertEquals('0.1', $response->getContent());
47+
$this->assertInternalType('string', $response->getContent());
4748

4849
$response = new JsonResponse(true);
4950
$this->assertSame('true', $response->getContent());
@@ -131,7 +132,8 @@ public function testStaticCreateWithSimpleTypes()
131132

132133
$response = JsonResponse::create(0.1);
133134
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
134-
$this->assertSame('0.1', $response->getContent());
135+
$this->assertEquals('0.1', $response->getContent());
136+
$this->assertInternalType('string', $response->getContent());
135137

136138
$response = JsonResponse::create(true);
137139
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);

0 commit comments

Comments
 (0)
0