InlineStyle icon indicating copy to clipboard operation
InlineStyle copied to clipboard

prevent escaping mailchimp variables

Open vladkucherov opened this issue 10 years ago • 5 comments

Hello there,

it looks like if you use variables inside quotes, they get escaped. for example:

<a href="mailto:*|EMAIL|*">*|EMAIL|*</a>

The result would be:

<a href="mailto:*%7CEMAIL%7C*>[email protected]</a>

Any ideas on how to make it ignore specific chars inside quotes?

vladkucherov avatar Apr 02 '14 06:04 vladkucherov

I think this is a DOMDocument problem. Can you reproduce this issue when you load the HTML into DOMDocument and then have it output HTML again?

christiaan avatar Apr 08 '14 12:04 christiaan

Yes, this is the case. apparently, DOMDocument tries to "fix" HTML attributes and reformat the data. I couldn't find a way to force him ignore the contents of attribute.

The only solution I found is to run over the output and replace back the escaped data - not good practice...

Also... for those who will get the same issue with Mailchimp / Mandrill, they provide an inliner of there own. just set "inline_css":true to your request.

vladkucherov avatar Apr 08 '14 14:04 vladkucherov

Hi there.

I have the same suggestion using Mailjet variables like [[PERMALINK]] or [[UNSUB_LINK_FR]]. But MailJet is not as smart as MailChimp and does not inline styles for you.

ambroisemaupate avatar Jan 22 '15 15:01 ambroisemaupate

You could use preg_replace_callback to replace all those instances with unique strings that are not escaped. Then after inlining replace them back.

I've marked it as a feature but I'm not so sure it is within the scope of this project. However I see this is a recurring problem for the intended usecase.

When you do get this working using the suggested substitute replace method described I would be happy to either include or link to your solution.

christiaan avatar Jan 22 '15 16:01 christiaan

Hello! Sorry to inject myself into a years-old conversation. Hoping that someone has since solved this?

staceypee avatar Dec 23 '20 21:12 staceypee