E-mail links created with WYSIWYG break if Message Body content ends with a period and clickthrough tracking is enabled
Overview
When the default CiviCRM WYSIWYG is used to create E-mail (mailto) links in the HTML field of a mailing, if the link's Message Body content ends in a period and "Track Click-Throughs" is enabled for the mailing, the link generated by CiviCRM and sent to mailing recipients is broken, yielding different incorrect results in each CMS tested.
This problem does not occur if Mosaico is used to edit mailing content and mailto link code is entered directly into the HTML source for the mailing. (No similar E-mail Link Type functionality is available in Mosaico.)
See an initial May 11 conversation in Mattermost: https://chat.civicrm.org/civicrm/pl/qzkdccudmbnk9mhh7j53p51zcr
Reproduction steps
- Either create a new mailing or continue a draft or unscheduled mailing.
- On the Tracking tab, make sure that Track Click-Throughs is enabled.
- On the Mailing tab, in the HTML field, enter some text, select it, then click the Link button in the WYSIWYG.
- In the Link Type field choose Email, populate the E-Mail Address and Message Subject fields, and in the Message Body field enter either a period or text ending in a period, e.g. Test body. Then click OK.
- Ensure that other required fields on the Mailing tab are populated, then either click Send test to send a test email or proceed to Review and Schedule the mailing to a group of test recipients.
- When you receive the mailing, view it in HTML format and click the E-mail link you created in the mailing.
Current behaviour
Behavior differs depending on the CMS, whether the person visiting the mailto link is logged in or not, and whether a test mailing or a full mailing is sent.
WordPress 5.7.2, CiviCRM 5.35.2, test mailing (CiviMail draft)
Whether logged in or logged out, the following error appears in the browser after the mailto link is clicked:
CRM_Core_Exception: Could not find valid value for u in /var/www/wp-content/plugins/civicrm/civicrm/CRM/Utils/Request.php on line 199
Exception trace
# Function Location
0 CRM_Utils_Request::retrieve() /var/www/wp-content/plugins/civicrm/civicrm/CRM/Utils/Request.php:199
1 CRM_Utils_Request::retrieveValue() /var/www/wp-content/plugins/civicrm/civicrm/CRM/Mailing/Page/Url.php:34
2 CRM_Mailing_Page_Url->run() /var/www/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:312
3 CRM_Core_Invoke::runItem() /var/www/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:68
4 CRM_Core_Invoke::_invoke() /var/www/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:36
5 CRM_Core_Invoke::invoke() /var/www/wp-content/plugins/civicrm/civicrm.php:1172
6 CiviCRM_For_WordPress->invoke() /var/www/wp-content/plugins/civicrm/includes/civicrm.basepage.php:354
7 CiviCRM_For_WordPress_Basepage->basepage_handler() /var/www/wp-includes/class-wp-hook.php:292
8 WP_Hook->apply_filters() /var/www/wp-includes/class-wp-hook.php:316
9 WP_Hook->do_action() /var/www/wp-includes/plugin.php:551
10 do_action_ref_array() /var/www/wp-includes/class-wp.php:763
11 WP->main() /var/www/wp-includes/functions.php:1291
12 wp() /var/www/wp-blog-header.php:16
13 require('/var/www/databas…') /var/www/index.php:17
14 {main}
Drupal 7.80 or Backdrop 1.19.1, CiviCRM 5.35.2, test mailing (CiviMail draft)
The mailto link points to something like https://example.com/civicrm/mailing/url?u=2419&qid=41780
, which is redirected to something like https://example.com/civicrm/mailing/href=%22mailto:test@example.com?subject=testing&body=test
in the browser. When logged out, this results in an Access Denied page; when logged in as a user with CiviCRM access, this leads to the CiviMail admin page.
WordPress 5.7.2, Drupal 7.80 or Backdrop 1.19.1, CiviCRM 5.35.2 or CiviCRM 5.36.1, full mailing
The text that was linked in the HTML field in CiviMail, and which was rendered as a (malfunctioning) mailto link in the test mailing, is not rendered as a link at all in a fully-sent mailing.
Expected behaviour
The link with tracking code should redirect to a properly-formed mailto link that then opens the system default email application or offers options for opening the mailto link.
Environment information
- Browser: Firefox 89.0, Chrome 91.0.4472.106, Safari 14
- CiviCRM: CiviCRM 5.35.2 and 5.36.1
- CMS: Backdrop 1.19.1, Drupal 7.80, WordPress 5.7.2
- Web Server: Apache 2.4