Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-11812

CiviMail: Using a token within an <a href> tag results in a double quotation mark, choking some mail viewers--with solution

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 4.2.7
    • Fix Version/s: Unscheduled
    • Component/s: CiviMail
    • Labels:
      None
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)

      Description

      In the HTML version of a civimail message, I'm including some tokens inside an <a href=""> URL, like this:

      <a href="https://ourwebsite.org/contributionpage?

      {contact.checksum}

      &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:

      <a href="https://ourwebsite.org/contributionpage?cs=32122fb8f9da781c76292268f621257d_1359594986_168&cid=19337"">Click here to renew, join, or make a special contribution</a>

      Note the double quotation marks after 19337.

      You can test this by entering a message in CiviMail then viewing the "preview mailing". Right click the preview mailing, choose "view iframe source" and you'll see that the <a href> tag ends with a double quotation mark as above. Most browsers silently accept the double quotation mark so you probably won't notice any visible problem with the HTML message. However the double quotation mark breaks some email programs html viewers, resulting in a garbled message.

      SOLUTION:

      The source of the extra quotation marks in CRM/Mailing/BAO/Mailing.php about line 1363. If you simply remove a few lines like this the problem is solved:

      // 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 .= '"'; }

      */

      I'm guessing that at some point the "previous regex" was fixed so that it doesn't gobble up the trailing quote, but this little hack was never removed.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              bhugh Brent Hugh
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: