Skip to content

Commit 0997ff5

Browse files
committed
bug symfony#28636 [HttpFoundation] X-Accel-Mapping does not use HTTP key=value syntax (c960657)
This PR was squashed before being merged into the 4.1 branch (closes symfony#28636). Discussion ---------- [HttpFoundation] X-Accel-Mapping does not use HTTP key=value syntax | Q | A | ------------- | --- | Branch? | 4.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? |no | Tests pass? | yes | Fixed tickets | symfony#28627 | License | MIT | Doc PR | The `X-Accel-Mapping` header does not use the standard HTTP key=value syntax, so using `HeaderUtils::combine()` breaks paths with upper-case letters. There is no good reason to use `HeaderUtils::combine()` in this case, so simply skip it. Commits ------- 09343c2 [HttpFoundation] X-Accel-Mapping does not use HTTP key=value syntax
2 parents 46fff8b + 09343c2 commit 0997ff5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ public function prepare(Request $request)
219219
// Do X-Accel-Mapping substitutions.
220220
// @link http://wiki.nginx.org/X-accel#X-Accel-Redirect
221221
$parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping', ''), ',=');
222-
$mappings = HeaderUtils::combine($parts);
223-
foreach ($mappings as $pathPrefix => $location) {
222+
foreach ($parts as $part) {
223+
list($pathPrefix, $location) = $part;
224224
if (substr($path, 0, \strlen($pathPrefix)) === $pathPrefix) {
225225
$path = $location.substr($path, \strlen($pathPrefix));
226226
break;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,8 @@ public function getSampleXAccelMappings()
337337
{
338338
return array(
339339
array('/var/www/var/www/files/foo.txt', '/var/www/=/files/', '/files/var/www/files/foo.txt'),
340-
array('/home/foo/bar.txt', '/var/www/=/files/,/home/foo/=/baz/', '/baz/bar.txt'),
340+
array('/home/Foo/bar.txt', '/var/www/=/files/,/home/Foo/=/baz/', '/baz/bar.txt'),
341+
array('/home/Foo/bar.txt', '"/var/www/"="/files/", "/home/Foo/"="/baz/"', '/baz/bar.txt'),
341342
);
342343
}
343344

0 commit comments

Comments
 (0)