CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • HREF URL with tokens in CiviMail body leads to extra quotation mark/bad HTML
Pages: [1]

Author Topic: HREF URL with tokens in CiviMail body leads to extra quotation mark/bad HTML  (Read 834 times)

flug

  • I post frequently
  • ***
  • Posts: 126
  • Karma: 12
HREF URL with tokens in CiviMail body leads to extra quotation mark/bad HTML
January 31, 2013, 05:08:41 am
In the HTML version of a civimail message, I'm including some tokens inside an <a href=""> URL, like this:

Code: [Select]
<a href="https://ourwebsite.org/contributionpage?{contact.checksum}&amp;cid={contact.contact_id}">Click here to renew, join, or make a special contribution</a></p>
The problem is when the tokens are inserted and the email sent, it comes out with a double quotation mark.  This breaks the HTML (in some browsers/email clients) and results in a garbled message.  It looks like this:

Code: [Select]
<a href="https://ourwebsite.org/contributionpage?cs=32122fb8f9da781c76292268f621257d_1359594986_168&amp;cid=19337"">Click here to renew, join, or make a special contribution</a>
Note the double quotation marks after 19337.

Is anyone else experiencing this?  (Note that some browsers silently ignore the double quotation marks and display the email correctly despite the error.  Others don't and display a garbled page.  To be sure, you'll have to look at the source code of the email message.)

I found the source of the extra quotation marks in CRM/Mailing/BAO/Mailing.php about line 1363:

Code: [Select]
      // add trailing quote since we've gobbled it up in a previous regex
      // function getPatterns, line 431
      if (preg_match('/^href[ ]*=[ ]*\'/', $url)) {
        $url .= "'";
      }
      elseif (preg_match('/^href[ ]*=[ ]*\"/', $url)) {
        $url .= '"';
      }

Just disabling that 'if' statement solved the problem for me.  But I'm wondering if that is the general solution, others are having this same problem, or what?  That 'if' statement must have been put in because it was needed at some point.

I tried to test using the demo site, but I couldn't get the $&*& thing to send me an email message--neither the test nor the real message worked.  I even tried putting in a working SMTP server and also firing off the cron job for civimail, neither helped.

That same 'problem' code is still in the current version of Mailing.php on fisheye (link). 

Any thoughts--anyone else having this problem? 

FYI I'm on 4.2.3 and Drupal 6.
« Last Edit: January 31, 2013, 05:26:58 am by flug »

flug

  • I post frequently
  • ***
  • Posts: 126
  • Karma: 12
Re: HREF URL with tokens in CiviMail body leads to extra quotation mark/bad HTML
February 01, 2013, 11:11:11 pm
Aha, I figured out a simple way to test--the bug appears in the "preview mailing" as well.  Most browsers silently accept the double "" so there is no noticeable problem.

However if you right click the preview mailing and "view frame source" then you can see the source and the fact that the double quotation mark does appear.  I just checked on the demo server.

FYI I've reported this as CRM 11812
« Last Edit: February 01, 2013, 11:20:17 pm by flug »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • HREF URL with tokens in CiviMail body leads to extra quotation mark/bad HTML

This forum was archived on 2017-11-26.