better response for getExtraSymbol

merge-requests/1/head
Julien Veyssier 2016-12-14 02:28:41 +01:00
parent 90c14a26e3
commit 20dace5880
1 changed files with 4 additions and 4 deletions

View File

@ -23,6 +23,7 @@ use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\IRequest; use OCP\IRequest;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\DataDisplayResponse;
use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
@ -188,13 +189,12 @@ class UtilsController extends Controller {
* @PublicPage * @PublicPage
*/ */
public function getExtraSymbol() { public function getExtraSymbol() {
$filename = str_replace(array('../', '..\\'), '', $_GET['name']); $filename = str_replace(array('../', '..\\', '/'), '', $_GET['name']);
$filepath = $this->config->getSystemValue('datadirectory').'/gpxedit/symbols/'.$filename; $filepath = $this->config->getSystemValue('datadirectory').'/gpxedit/symbols/'.$filename;
$filecontent = file_get_contents($filepath); $filecontent = file_get_contents($filepath);
echo $filecontent; $response = new DataDisplayResponse(
$response = new Response( $filecontent, \OCP\AppFramework\Http::STATUS_OK, Array('Content-type'=>'image/png')
); );
$response->setHeaders(Array('Content-type'=>'image/png'));
$csp = new ContentSecurityPolicy(); $csp = new ContentSecurityPolicy();
$csp->addAllowedImageDomain('*') $csp->addAllowedImageDomain('*')
->addAllowedMediaDomain('*') ->addAllowedMediaDomain('*')