spatie / mailcoach-support

Questions and support for Mailcoach
https://mailcoach.app
31 stars 2 forks source link

Advice: wrong encoding of of "|" character in links #214

Closed electronick86 closed 4 years ago

electronick86 commented 4 years ago

Hi!

I'm not sure my problem is due to mailcoach at all, but as I can't explain it, I would like to get your advise.

My customer has a website with URL that contains pipes ("|") characters.

<html>
  <head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Test Email</title>

  </head>
  <body>
  <span class="preheader">This is a test email</span>
    <p><a href="https://testdomain.be/?ed=MYED#|SU" target="_blank">This links contains | and # characters</a> </p>
  </body>    
</html>

When i create this mail, the preview of mailcoach contains a correct link.

Capture d’écran 2020-06-18 à 08 35 29

Once the email is sent, the link is changed with the pipe character encoded to %7C.

_2__MailDev_et_Newsletter_7Dimanche

Do you have an idea of how could I have the pipe character in the email received?

Thanks!!

electronick86 commented 4 years ago

I see here that specials characters should be encoded.

I suppose that the encoding done by mailcoach is the expected behavior and that the problem is on my client site. His website should interpret these two URLs exactly the same way (https://testdomain.be/?ed=MYED#|SU and https://testdomain.be/?ed=MYED#%7CSU).

Unfortunately, it's not the case ;-)

riasvdv commented 4 years ago

This is definitely something the website should support, url encoding/decoding is a standard practice to make HTML safe to process and send.

If you'd like to change this, you can replace the PrepareEmailHtmlAction with a version of your own in the mailcoach.actions.prepare_email_html config key that extends our class and calls urldecode on the resulting HTML. This could have unintended side effects though, so I suggest testing it thoroughly before using it on live campaigns.

electronick86 commented 4 years ago

Thanks a lot @riasvdv !