mirror of https://github.com/MISP/MISP
fix: [dashboard:csvExport] Quote elements and correctly apply line break
parent
1f839d91c5
commit
3c097f8202
|
@ -33,7 +33,7 @@ class AppController extends Controller
|
|||
|
||||
public $helpers = array('OrgImg', 'FontAwesome', 'UserName');
|
||||
|
||||
private $__queryVersion = '154';
|
||||
private $__queryVersion = '155';
|
||||
public $pyMispVersion = '2.4.174';
|
||||
public $phpmin = '7.2';
|
||||
public $phprec = '7.4';
|
||||
|
|
|
@ -207,13 +207,16 @@ class DashboardsController extends AppController
|
|||
$csv = array_map(function($row) {
|
||||
$flattened = array_values(Hash::flatten($row));
|
||||
$stringified = array_map('strval', $flattened);
|
||||
return implode(',', $stringified);
|
||||
$quotified = array_map(function($item) { return sprintf('"%s"', $item); }, $stringified);
|
||||
return implode(',', $quotified);
|
||||
}, $toConvert);
|
||||
$rowKey = implode(',', array_map('strval', array_keys(Hash::flatten($toConvert[0]))));
|
||||
$rowKey = implode(',', array_map(function ($item) {
|
||||
return sprintf('"%s"', $item);
|
||||
}, array_map('strval', array_keys(Hash::flatten($toConvert[0])))));
|
||||
$csv = $rowKey . PHP_EOL . implode(PHP_EOL, array_values($csv));
|
||||
}
|
||||
}
|
||||
return $this->RestResponse->viewData($csv, 'text/csv');
|
||||
return $this->RestResponse->viewData($csv, 'text/csv', false, true);
|
||||
}
|
||||
|
||||
$this->layout = false;
|
||||
|
|
|
@ -5527,8 +5527,10 @@ function resetDashboardGrid(grid, save = true) {
|
|||
widget: $element.attr('widget')
|
||||
},
|
||||
success:function (data) {
|
||||
data = JSON.stringify(data, null, 2);
|
||||
var blob=new Blob([data], {type: 'application/json'});
|
||||
if (export_type == 'json') {
|
||||
data = JSON.stringify(data, null, 2);
|
||||
}
|
||||
var blob = new Blob([data], { type: (export_type == 'json' ? 'application/json' : 'text/csv') });
|
||||
var link=window.document.createElement('a');
|
||||
link.href=window.URL.createObjectURL(blob);
|
||||
link.download=$element.attr('widget') + "_" + container_id + "_export." + export_type;
|
||||
|
|
Loading…
Reference in New Issue