HTML Encoding in field - pure html populated | Community
Skip to main content
Kacper_Gawlik-2
New Participant
April 27, 2021
Solved

HTML Encoding in field - pure html populated

  • April 27, 2021
  • 1 reply
  • 3547 views

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-something/ba-p/242032 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

 

I would appreciate any help here.

Best,
Kacper

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

@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)


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

1 reply

SanfordWhiteman
New Participant
April 27, 2021

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-2
New Participant
April 27, 2021

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:

Do you think there is something I am missing?

Thanks,
Kacper

SanfordWhiteman
New Participant
April 27, 2021
It has to be in there twice... maybe once with your first take and again with the macro.