Skip to content

Commit 46d05ec

Browse files
committed
bug #13708 [2.3] [HttpFoundation] fixed param order for Nginx's x-accel-mapping (phansys)
This PR was merged into the 2.3 branch. Discussion ---------- [2.3] [HttpFoundation] fixed param order for Nginx's x-accel-mapping | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | kinda | Deprecations? | no | Tests pass? | yes | Fixed tickets | #13502 | License | MIT | Doc PR | n/a Inverted path and location directives for x-accel-mapping header (fixes #13502). Before: ```proxy_set_header X-Accel-Mapping /internal/=/var/www/example.com/``` After: ```proxy_set_header X-Accel-Mapping /var/www/example.com/=/internal/``` It could be a BC break since the response will fail if someone sends this header honoring the previous signature, thus I need some feedback in order to choose the right branch for this change. Commits ------- 9f9f230 [2.3] [HttpFoundation] fixed param order for Nginx's x-accel-redirect
2 parents 7d6c7a3 + 9f9f230 commit 46d05ec

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,13 @@ public function prepare(Request $request)
194194
$path = $this->file->getRealPath();
195195
if (strtolower($type) == 'x-accel-redirect') {
196196
// Do X-Accel-Mapping substitutions.
197+
// @link http://wiki.nginx.org/X-accel#X-Accel-Redirect
197198
foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) {
198199
$mapping = explode('=', $mapping, 2);
199200

200201
if (2 == count($mapping)) {
201-
$location = trim($mapping[0]);
202-
$pathPrefix = trim($mapping[1]);
202+
$pathPrefix = trim($mapping[0]);
203+
$location = trim($mapping[1]);
203204

204205
if (substr($path, 0, strlen($pathPrefix)) == $pathPrefix) {
205206
$path = $location.substr($path, strlen($pathPrefix));

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ public function testAcceptRangeNotOverriden()
222222
public function getSampleXAccelMappings()
223223
{
224224
return array(
225-
array('/var/www/var/www/files/foo.txt', '/files/=/var/www/', '/files/var/www/files/foo.txt'),
226-
array('/home/foo/bar.txt', '/files/=/var/www/,/baz/=/home/foo/', '/baz/bar.txt'),
225+
array('/var/www/var/www/files/foo.txt', '/var/www/=/files/', '/files/var/www/files/foo.txt'),
226+
array('/home/foo/bar.txt', '/var/www/=/files/,/home/foo/=/baz/', '/baz/bar.txt'),
227227
);
228228
}
229229

0 commit comments

Comments
 (0)