mirror of
https://github.com/grocy/grocy.git
synced 2025-08-15 18:26:00 +00:00
Make sure to clean the response before returning files
Was a problemw when returning images and there were leading empty lines in config.php which seem to get added to the response always...
This commit is contained in:
@@ -49,6 +49,7 @@ class CalendarApiController extends BaseApiController
|
|||||||
$vCalendar->addEvent($vEvent);
|
$vCalendar->addEvent($vEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ob_clean(); // Make sure to ONLY return the file
|
||||||
$response->write((new CalendarFactory())->createCalendar($vCalendar));
|
$response->write((new CalendarFactory())->createCalendar($vCalendar));
|
||||||
$response = $response->withHeader('Content-Type', 'text/calendar; charset=utf-8');
|
$response = $response->withHeader('Content-Type', 'text/calendar; charset=utf-8');
|
||||||
return $response->withHeader('Content-Disposition', 'attachment; filename="grocy.ics"');
|
return $response->withHeader('Content-Disposition', 'attachment; filename="grocy.ics"');
|
||||||
|
@@ -49,6 +49,7 @@ class FilesApiController extends BaseApiController
|
|||||||
|
|
||||||
if (file_exists($filePath))
|
if (file_exists($filePath))
|
||||||
{
|
{
|
||||||
|
ob_clean(); // Make sure to ONLY return the file
|
||||||
$response->write(file_get_contents($filePath));
|
$response->write(file_get_contents($filePath));
|
||||||
$response = $response->withHeader('Cache-Control', 'max-age=2592000');
|
$response = $response->withHeader('Cache-Control', 'max-age=2592000');
|
||||||
$response = $response->withHeader('Content-Type', mime_content_type($filePath));
|
$response = $response->withHeader('Content-Type', mime_content_type($filePath));
|
||||||
@@ -80,6 +81,7 @@ class FilesApiController extends BaseApiController
|
|||||||
|
|
||||||
if (file_exists($filePath))
|
if (file_exists($filePath))
|
||||||
{
|
{
|
||||||
|
ob_clean(); // Make sure to ONLY return the file
|
||||||
$response->write(file_get_contents($filePath));
|
$response->write(file_get_contents($filePath));
|
||||||
$response = $response->withHeader('Cache-Control', 'max-age=2592000');
|
$response = $response->withHeader('Cache-Control', 'max-age=2592000');
|
||||||
$response = $response->withHeader('Content-Type', mime_content_type($filePath));
|
$response = $response->withHeader('Content-Type', mime_content_type($filePath));
|
||||||
|
Reference in New Issue
Block a user