Apostrophes in richtext fields don't get exported properly in CiviReport
I couldn't find an existing issue but I did find some internal notes from 6 years ago and a quickie-patch I made on a site back then. I've confirmed it's still an issue on dmaster.demo:
- Create e.g. an activity and put a word with an apostrophe in the details field. Make sure your grammar is correct and it's not a misplaced apostrophe or I will bug you about it.
- Run the activity details civireport and on the columns tab include activity details, and in the filters pick something that will include the activity you created.
- From the actions dropdown choose export to csv.
- The csv will contain
'instead of an apostrophe.
The quickie-fix I had made was to change this line: https://github.com/civicrm/civicrm-core/blob/5.24.6/CRM/Report/Utils/Report.php#L257 from
$value = str_replace('"', '""', html_entity_decode(strip_tags($value)));
$value = str_replace('"', '""', html_entity_decode(strip_tags($value), ENT_QUOTES | ENT_HTML401));
While that might still fix it even 6 years later, it also seems like this shouldn't be a hand-rolled thing in 2020. So TBD.