Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function prepare(Request $request): static
$path = $location.substr($path, \strlen($pathPrefix));
// Only set X-Accel-Redirect header if a valid URI can be produced
// as nginx does not serve arbitrary file paths.
$this->headers->set($type, $path);
$this->headers->set($type, rawurlencode($path));
$this->maxlen = 0;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,15 @@ public function testXAccelMapping($realpath, $mapping, $virtual)
$property->setValue($response, $file);

$response->prepare($request);
$this->assertEquals($virtual, $response->headers->get('X-Accel-Redirect'));
$header = $response->headers->get('X-Accel-Redirect');

if ($virtual) {
// Making sure the path doesn't contain characters unsupported by nginx
$this->assertMatchesRegularExpression('/^([^?%]|%[0-9A-F]{2})*$/', $header);
$header = rawurldecode($header);
}

$this->assertEquals($virtual, $header);
}

public function testDeleteFileAfterSend()
Expand Down Expand Up @@ -361,6 +369,7 @@ public static function getSampleXAccelMappings()
['/home/Foo/bar.txt', '/var/www/=/files/,/home/Foo/=/baz/', '/baz/bar.txt'],
['/home/Foo/bar.txt', '"/var/www/"="/files/", "/home/Foo/"="/baz/"', '/baz/bar.txt'],
['/tmp/bar.txt', '"/var/www/"="/files/", "/home/Foo/"="/baz/"', null],
['/var/www/var/www/files/foo%.txt', '/var/www/=/files/', '/files/var/www/files/foo%.txt'],
];
}

Expand Down
Loading