Contribution receipt has donor's name printed twice, once with non-printable characters
Overview
Contribution receipts, notably those created with the Stripe extension, display the donor's information as follows:
JaneMarySmith <$first . \x01 . $middle . \x01 . $last>
Jane Mary Smith <$first . \x20 . $middle . \x20 . $last>
123 Main St
...
The two \x01 characters (ASCII SOH, CRM_Core_DAO::VALUE_SEPARATOR) are displayed as boxes in some email clients, although they aren't displayable in this bug report.
The message template "Contributions - Receipt (on-line)" includes:
{if $billingName}
<tr>
<th {$headerStyle}>
{ts}Billing Name and Address{/ts}
</th>
</tr>
<tr>
<td colspan="2" {$valueStyle}>
{$billingName}<br />
{$address|nl2br}<br />
{$email}
</td>
</tr>
{elseif $email}
For Stripe contributions, $billingName contains the first/middle/last names separated by SOH characters, as found in civicrm_address.name. The {if $billingName} block therefore gets printed, including both $billingName and the $address variable which contains the second instance of the donor's name, followed by their address.
The SOH characters in the first line of $address (the donor's name) are replaced with spaces in CRM_Core_BAO_Address::addDisplay().
Contributions via Paypal standard, in contrast, do not display the $billingName block as addresses created that way store NULL in civicrm_address.name.
Reproduction steps
- Create a contribution with CiviCRM Stripe extension v. 6.4.2.
- Observe the Billing Name and Address section of the emailed receipt.
Current behaviour
The donor's name is printed twice. Once with SOH separators, and again with spaces. If the middle name is blank, the second instance contains two spaces between first and last name.
Expected behaviour
The name should be printed once, with a single space between non-blank name components.
Additional comments
- Perhaps the fix is to simply remove "$billingName<br />" from the template(s). Ideally, the double spaces in the case of a null middle name should be corrected also.
- Event and Membership templates seem to have the same structure as the template shown above.
- The Thank You page displays the donor's name as expected -- only once, with a single \x20 character between first and last name.
Environment information
- CiviCRM: 5.28.2
- CiviCRM Stripe extension v. 6.4.2
- mjwshared extension v. 0.8.1
- PHP: 7.3
- CMS: Drupal 7.72