X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FReport%2FUtils%2FReport.php;h=b3fd9556fa74b4c2e18444ff6ed1523f95775f21;hb=d0d1c38b95f7daac9183d97ec012c9949c1a1feb;hp=627c2a97c73c664d110868e6671177f8fb64f059;hpb=3de0809220f2e53086778e88d849abfdbac38e37;p=civicrm-core.git diff --git a/CRM/Report/Utils/Report.php b/CRM/Report/Utils/Report.php index 627c2a97c7..b3fd9556fa 100644 --- a/CRM/Report/Utils/Report.php +++ b/CRM/Report/Utils/Report.php @@ -209,10 +209,6 @@ WHERE inst.report_id = %1"; //Force a download and name the file using the current timestamp. $datetime = date('Ymd-Gi', $_SERVER['REQUEST_TIME']); CRM_Utils_System::setHttpHeader('Content-Disposition', 'attachment; filename=Report_' . $datetime . '.csv'); - // Output UTF BOM so that MS Excel copes with diacritics. This is recommended as - // the Windows variant but is tested with MS Excel for Mac (Office 365 v 16.31) - // and it continues to work on Libre Office, Numbers, Notes etc. - echo "\xEF\xBB\xBF"; echo self::makeCsv($form, $rows); CRM_Utils_System::civiExit(); } @@ -228,7 +224,11 @@ WHERE inst.report_id = %1"; */ public static function makeCsv(&$form, &$rows) { $config = CRM_Core_Config::singleton(); - $csv = ''; + + // Output UTF BOM so that MS Excel copes with diacritics. This is recommended as + // the Windows variant but is tested with MS Excel for Mac (Office 365 v 16.31) + // and it continues to work on Libre Office, Numbers, Notes etc. + $csv = "\xEF\xBB\xBF"; // Add headers if this is the first row. $columnHeaders = array_keys($form->_columnHeaders); @@ -251,7 +251,7 @@ WHERE inst.report_id = %1"; $value = $row[$v] ?? NULL; if (isset($value)) { // Remove HTML, unencode entities, and escape quotation marks. - $value = str_replace('"', '""', html_entity_decode(strip_tags($value))); + $value = str_replace('"', '""', html_entity_decode(strip_tags($value), ENT_QUOTES | ENT_HTML401)); if (CRM_Utils_Array::value('type', $form->_columnHeaders[$v]) & 4) { if (CRM_Utils_Array::value('group_by', $form->_columnHeaders[$v]) == 'MONTH' ||