Reputation: 10692
I am trying to display an email formatted as "FirstName LastName <[email protected]>"
in HTML, and it is only displaying "FirstName LastName".
Pseudo-code:
<cfset LOCAL.From = "FirstName LastName <[email protected]>" />
<cfoutput>#Local.From#</cfoutput>
I know I can replace the less-than and greater-than signs with lt;
and gt;
, but I'm looking for a better way than Replace(Replace(LOCAL.Form, "<", ";lt;"), ">", ">")
.
I'm not very good with Regular Expressions, if that's the way to go, so show me a good RegEx for this, if you'd like.
Or, if this can be done simply with some ColdFusion function, that's great too.
Upvotes: 1
Views: 230
Reputation: 936
Assuming you are getting the FirstName and LastName variables from somewhere, you need to specify them as output. The way you've coded it, the string would always be the same and not dynamic.
<cfset FirstName = "John">
<cfset LastName = "Doe">
<cfset LOCAL.From = "#FirstName# #LastName# <#FirstName##LastName#@domain.com>" />
<cfoutput>#HTMLEditFormat(Local.From)#</cfoutput>
Upvotes: 0
Reputation: 57832
You're looking for HTML encoding, rather than string replacement. Use HtmlEditFormat.
Possibly related: How to encode HTML form in coldfusion?
Upvotes: 2