6

I'm trying to send out a mailing via CiviMail, and we have a link to the RSVP URL of our CiviCRM event. However, whenever we've sent out the test emails, it seems that the URL is getting messed up by the included WYSIWYG: CKEditor. This is the problem we are experiencing. If you take a URL, say

http://example.com/index.php?option=com_civicrm&id=172&lang=en&reset=1&task=civicrm/event/register

It gets replaced with the following URL:

http://example.com/index.php?option=com_civicrm&id=172&lang=en&reset=1&task=civicrm/event/register

Now the difference isn't all that noticeable, but the &s get replaced with &s. I was able to find a workaround by editing the source of the email and replacing all of the &s and not switching back to WYSIWYG view before sending it out. However this a less-than-ideal, band-aid solution. Does anyone have an idea of how to fix this issue?

note: I tried installing the TinyMCE CiviCRM extension, and that did not solve the problem, the URL's were still getting jumbled.

4 Answers 4

3

I feel your pain. Using wysiwyg editors to write emails is like using salt to heal a bleeding wound. It might have a purpose, but probably not in this context. and in this context, it hurts. A lot.

Anyway, back to your question: are you having the replacement in the href or "only" when you leave the link as part of the text you send?

The latest version of civi should behave correctly, otherwise, you can disable the replacement of the & into & (I've done it, it's not 100% html strict compatible, but seems to work fine with 100% of the real mail clients): here's an explanation on how to do it: Escaping quotes in ckeditor breaks smarty-syntax

and a more generic question about how to disable the wysiwyg editor: How to disable or fix the wysiwyg editor on civimail

3
  • Okay, that makes sense. Thank you for the links! Is there any reason that the built-in configuration for CKEditor is so limited? It only lets you change which buttons show up. I think having functionality to do that would be very helpful.
    – Brad Xanti
    Mar 14, 2016 at 14:24
  • And to answer your question, it only replaces the &'s to &'s when I switch back from editing the source to WYSIWYG view. If I click to go to the next step without going back to WYSIWYG view, the link retains its &'s.
    – Brad Xanti
    Mar 14, 2016 at 14:29
  • I'm having this same problem, and we're on wordpress 4.4.6 and Civi 4.7.6 - which I understand is the latest. We've been having this issue since the upgrading to 4.7 and it's very cumbersome to train volunteers to do a workaround like this. So, it appears an upgrade doesn't solve it. The problem is in Civi still.
    – Ben
    Apr 14, 2016 at 19:00
2

From my tests, it seems like this mostly happens when the URL goes through the URL tracking of CiviCRM.

For example, if I send myself a test email from CiviMail, the URL will have a & in the URL, but my browser/email reader doesn't mind.

It only becomes a problem when I do a full mailing and track the URL:

$ wget -O /dev/null -S "https://example.org/sites/all/modules/civicrm/extern/url.php?u=1234&qid=87654"
  HTTP/1.1 302 Found
  Location: https://example.org/civicrm/event/info?reset=1&id=678

In that case, the URL causes a CiviCRM fatal error.

Edit: this is by no means a proper solution, but in the mean time I am using this fix:

diff --git a/CRM/Mailing/Event/BAO/TrackableURLOpen.php b/CRM/Mailing/Event/BAO/TrackableURLOpen.php
index 18e3284..0840e3d 100644
--- a/CRM/Mailing/Event/BAO/TrackableURLOpen.php
+++ b/CRM/Mailing/Event/BAO/TrackableURLOpen.php
@@ -90,6 +90,10 @@ class CRM_Mailing_Event_BAO_TrackableURLOpen extends CRM_Mailing_Event_DAO_Track
     $open->time_stamp = date('YmdHis');
     $open->save();

+    $search->url = preg_replace('/&/', '&', $search->url);
+
     return $search->url;
   }
6
  • Thanks for the fix! So, is this something we should put in the issue tracker? Seems like potentially a pretty big issue.
    – Brad Xanti
    May 20, 2016 at 15:56
  • Yep please do. This seems to affect a lot of people. I just ran into the issue again for another organisation, so I am now patching all my clients.
    – bgm
    May 20, 2016 at 15:58
  • Sorry, I'm not really familiar with how to do that. I'm happy to submit it, I just don't know how.
    – Brad Xanti
    May 20, 2016 at 16:03
  • You can create a new issue here: issues.civicrm.org - just enter a clear title based on this thread, and a link to this page. Post the link in a comment here too. I'll go fill in the details if necessary. I would do it for you, but you profile says you are a programmer, so may as well take the opportunity ;-)
    – bgm
    May 20, 2016 at 16:11
  • 2
    Originally raised here, and already fixed in 4.7.8 =] Please do test this as part of the testing week for the new release candidate! issues.civicrm.org/jira/browse/CRM-18320
    – John
    May 23, 2016 at 14:58
1

There's two things here.

The first is where the link is to. That should not contain the amp;s. You should only be able to see this in the source.

The next is how the link appears. This bit should contain the amp;s to make it HTML friendly.

Links in source view should be of the form:

Click <a href="http://linknotcontainingamps.net">http://linkcontainingamps.net</a>

Or even

Click <a href="http://linknotcontainingamps.net">here</a>
1
  • Well, that's actually what it does look like. It looks something like this: <a href=".../index.php?option=com_civicrm&id=172&lang=en&reset=1&task=civicrm/event/register">RSVP Here</a>. The problem that's happening is that when I switch from editing the source to the WYSIWYG view, it replaces all of the &s inside of the href to &amp;s, thus jumbling the URL the link leads to.
    – Brad Xanti
    Mar 14, 2016 at 14:07
1

CORRECTED: I too am having this problem & it has also been happening with my Civi/Wordpress & Civi/Drupal sites since 4.7 upgrade. Adding a link to an event or contribution page via the link button seems to work fine, but the resultant html code contains escaped ampersands (these don't show when the link is reopened using the link button) that make the link unusable. As noted above, the only workaround seems to be to correct the source and then not use WYSIWYG again - frustrating if you have content corrections to make thereafter.

I have applied the various CKEditor configuration directives suggested in the links above to media/civicrm/persist/crm-ckeditor-config.js with no result. I can confirm that other directives when used here cause corresponding changes in the editor (e.g style or help buttons), but the config.entities directives etc don't affect escape processing.

This doesn't seems to be an issue with CKEditor, as the same link inserted into an Event description works perfectly well, so must be an issue with the Civimail implementation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.