Avoid truncated UTF-8 strings when using substr()
CRM_Core_BAO_Mapping::getCustomGroupName()
truncates custom group names when longer than 10 characters using substr()
, which causes multibyte characters being cut in half when at the truncating position.
This should use CRM_Utils_String::ellipsify()
instead, which utilises mb_substr()
.
Maybe someone with more core code insight should inspect a grep substr(
result for more places where that happens.
Steps to reproduce:
- Create a custom field group with a name with a multibyte character at the 10th position, e.g. German umlaut
ö
- Add any custom field
- Do a contact search, select some contacts, choose "export" action
- Choose "Select fields to export"
- Notice a JavaScript console error: "Uncaught syntax error: Unexpected token ,", inspect the source and notice the missing custom field name for the field in the custom field group
Edit: It should be noted that this causes the export field selection screen not working (no fields can be selected) anymore because of the JavaScript error