1

I am getting JSON response, and the same response I am printing on Lightning Component, the issue I am facing is I am getting response in HTML and I want print the output of the HTML.

Here is the response I am getting

[
check=1,
xyz=0, 
date=Mon May 08 14:34:27 EDT 2017, 
Fax=<a href='mailto:[email protected]?Subject=Send a PDF to this record' title='email to this record'>+1 (098) 765-4321</a>
]

and I want to print fax as output mailto link,

In Component I am doing like this below

{v.Data.Fax}

But getting the output like this

<a href='mailto:[email protected]?Subject=Send a PDF to this record' title='email to this record'>+1 (098) 765-4321</a>
3
  • 4
    Can try aura:unescapedHtml
    – Praveen
    Commented May 8, 2017 at 19:22
  • you are the best , it worked :) Commented May 8, 2017 at 21:02
  • I'll convert the comment as answer, accept it so that we can close the question.
    – Praveen
    Commented May 9, 2017 at 9:33

1 Answer 1

2

You could use aura:unescaptedHTML to render HTML content in view. Also be very cautions when using this component because it might open a security vector as the doc states:

This component outputs value as unescaped HTML, which introduces the possibility of security vulnerabilities in your code. You must sanitize user input before rendering it unescaped, or you will create a cross-site scripting (XSS) vulnerability.

So only use <aura:unescapedHtml> with trusted or sanitized sources of data.

For sanitizing the HTML content you can use any of the below libraries:

1.sanitize-html

2.DOMPurify

3.secureFilter which mentioned in the Lightning Security

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .