bug #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 #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 | #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
-------
09343c27d7
[HttpFoundation] X-Accel-Mapping does not use HTTP key=value syntax
This commit is contained in:
commit
0997ff5a7c
@ -219,8 +219,8 @@ class BinaryFileResponse extends Response
|
||||
// Do X-Accel-Mapping substitutions.
|
||||
// @link http://wiki.nginx.org/X-accel#X-Accel-Redirect
|
||||
$parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping', ''), ',=');
|
||||
$mappings = HeaderUtils::combine($parts);
|
||||
foreach ($mappings as $pathPrefix => $location) {
|
||||
foreach ($parts as $part) {
|
||||
list($pathPrefix, $location) = $part;
|
||||
if (substr($path, 0, \strlen($pathPrefix)) === $pathPrefix) {
|
||||
$path = $location.substr($path, \strlen($pathPrefix));
|
||||
break;
|
||||
|
@ -337,7 +337,8 @@ class BinaryFileResponseTest extends ResponseTestCase
|
||||
{
|
||||
return array(
|
||||
array('/var/www/var/www/files/foo.txt', '/var/www/=/files/', '/files/var/www/files/foo.txt'),
|
||||
array('/home/foo/bar.txt', '/var/www/=/files/,/home/foo/=/baz/', '/baz/bar.txt'),
|
||||
array('/home/Foo/bar.txt', '/var/www/=/files/,/home/Foo/=/baz/', '/baz/bar.txt'),
|
||||
array('/home/Foo/bar.txt', '"/var/www/"="/files/", "/home/Foo/"="/baz/"', '/baz/bar.txt'),
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user