SOLVED

Re: HTML Encoding in field - pure html populated

Go to solution
Kacper_Gawlik
Level 2

HTML Encoding in field - pure html populated

Hello,

We have an issue with field to which html code is populated and then referred in Velocity Script.
Everything worked fine till Friday April 23rd 21' when it stopped and essentialy all characters "<" and ">" are disrupting our code and when email is populated in Preview whe see pure html code where there should be regular email content.

We are using option HTML Encode checked on a field level.
Also tried solutions described in here: https://nation.marketo.com/t5/Product-Blogs/Even-when-Velocity-isn-t-doing-anything-it-s-doing-somet... but still no luck.

Our dev suggested workaround and use something like within the Velocity token:

#set ($valueCC = "${lead.commoditiesBulletinContentOil}")
$valueCC.toString().replaceAll("\&lt\;","<").replaceAll("\&gt\;",">");

but then there are some &nbsp left

Kacper_Gawlik_0-1619503627322.png

 

I would appreciate any help here.

Best,
Kacper

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: HTML Encoding in field - pure html populated

Yes, in the 2 instances I tested that had the bug, it was fixed tonight — while I was working on the bug report.

View solution in original post

7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: HTML Encoding in field - pure html populated

This is the same bug (and the same code???) one of your coworkers reported elsewhere, I believe.  Have since confirmed it in another Marketo instance, but not on 2 others.

 

You don't need a regex here. This will do:

 

#macro( unescapeHTML_v1 $escaped )
#set( $unescaped = $escaped.replace("&lt;","<").replace("&gt;",">").replace("&amp;","&") )
${unescaped}
#end

 

 

Put that in a Velocity token included at the top of the email.

 

Then call it using

 

#unescapeHTML_v1($lead.commoditiesBulletinContentOil)

 

etc.

Kacper_Gawlik
Level 2

Re: HTML Encoding in field - pure html populated

Thanks Sanford!

It works to some point but it duplicates content somehow. I re-checked if each token (set-up per each field) refers to the correct field so eliminated scenario when something is duplicated:

Kacper_Gawlik_0-1619525256709.png

Do you think there is something I am missing?

Thanks,
Kacper

SanfordWhiteman
Level 10 - Community Moderator

Re: HTML Encoding in field - pure html populated

It has to be in there twice... maybe once with your first take and again with the macro.
SanfordWhiteman
Level 10 - Community Moderator

Re: HTML Encoding in field - pure html populated

@Kacper_Gawlik @Anthony_Figgin1 I've been looking into this further and — unless it's been partially fixed in the interim — is it possible the bug only existed in Preview (which is still a bug) but not in the actual received email? That's the behavior I'm seeing now.

Peter_Rytter
Level 2

Re: HTML Encoding in field - pure html populated

@SanfordWhiteman Just as an FYI, I've experienced problems with html (directly from a lead token though, no velocity involved) not rendering properly in the Preview but working just fine in the actual email. Like Kacper, the issue started around Friday (23rd) but seems to have been fixed now. (Ashburn instance)

SanfordWhiteman
Level 10 - Community Moderator

Re: HTML Encoding in field - pure html populated

Yes, in the 2 instances I tested that had the bug, it was fixed tonight — while I was working on the bug report.

Kacper_Gawlik
Level 2

Re: HTML Encoding in field - pure html populated

Thank you All for your swift help and support!