-
Bug
-
Resolution: Fixed
-
Minor
-
4.3.8, 4.4.4, 4.5
The xsendfile function in Moodle's
lib/xsendfilelib.php
|
fails when the file name contains special characters such as ?, and % when using Nginx. This issue results in the function returning an error and the file not being served as expected.
Steps to Reproduce:
1. Ensure that the $CFG->xsendfile setting is enabled in the config.php file.
2. Make Sure $CFG->dataroot directory is writable.
3. In the root directory of your Moodle installation, create a file named _ test-xsendfile.php_. Add the following code to test-xsendfile.php:
<?php
|
include('config.php'); |
$ignored = make_request_directory(); |
|
$filename = 'hello % world.txt'; |
$path = "$CFG->dataroot/$filename"; |
file_put_contents($path, "This is a file called $filename\n"); |
send_file($path, $filename, 0, 0, false, true); |
|
4. Open a web browser and navigate to the URL: http://yourmoodleurl/test-xsendfile.php
5. The file should be downloaded by the browser using the X-Sendfile header. However, you will encounter an error message:
This site can’t be reached
|
The webpage at [https://yourmoodleurl/test-xsendfile.php] might be temporarily down or it may have moved permanently to a new web address.
|
ERR_INVALID_RESPONSE
|